robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. KeyesMerge #39031 appimage, rename org.neovim.nvim.appdata.xml91eb6399e9

master
3.3 KiB101 linesraw
1#!/usr/bin/env bash
2
3# Usage:
4#   ./scripts/release.sh
5#   ./scripts/release.sh --use-current-commit
6#   ./scripts/release.sh --only-bump
7#
8# Performs steps to tag a release.
9#
10# Steps:
11#   Create the "release" commit:
12#     - CMakeLists.txt: Unset NVIM_VERSION_PRERELEASE
13#     - CMakeLists.txt: Unset NVIM_API_PRERELEASE
14#     - Create test/functional/fixtures/api_level_N.mpack
15#     - Add date and version to runtime/org.neovim.nvim.appdata.xml
16#     - Tag the commit.
17#   Create the "version bump" commit:
18#     - CMakeLists.txt: Set NVIM_VERSION_PRERELEASE to "-dev"
19
20set -e
21set -u
22set -o pipefail
23
24ARG1=${1:-no}
25
26__sed=$( [ "$(uname)" = Darwin ] && echo 'sed -E' || echo 'sed -r' )
27
28cd "$(git rev-parse --show-toplevel)"
29
30__DATE=$(date +'%Y-%m-%d')
31__LAST_TAG=$(git describe --abbrev=0)
32[ -z "$__LAST_TAG" ] && { echo 'ERROR: no tag found'; exit 1; }
33__VERSION_MAJOR=$(grep 'set(NVIM_VERSION_MAJOR' CMakeLists.txt\
34  |$__sed 's/.*NVIM_VERSION_MAJOR ([[:digit:]]+).*/\1/')
35__VERSION_MINOR=$(grep 'set(NVIM_VERSION_MINOR' CMakeLists.txt\
36  |$__sed 's/.*NVIM_VERSION_MINOR ([[:digit:]]+).*/\1/')
37__VERSION_PATCH=$(grep 'set(NVIM_VERSION_PATCH' CMakeLists.txt\
38  |$__sed 's/.*NVIM_VERSION_PATCH ([[:digit:]]+).*/\1/')
39__VERSION="${__VERSION_MAJOR}.${__VERSION_MINOR}.${__VERSION_PATCH}"
40__API_LEVEL=$(grep 'set(NVIM_API_LEVEL ' CMakeLists.txt\
41  |$__sed 's/.*NVIM_API_LEVEL ([[:digit:]]+).*/\1/')
42{ [ -z "$__VERSION_MAJOR" ] || [ -z "$__VERSION_MINOR" ] || [ -z "$__VERSION_PATCH" ]; } \
43  &&  { echo "ERROR: version parse failed: '${__VERSION}'"; exit 1; }
44__RELEASE_MSG="NVIM v${__VERSION}
45
46"
47__BUMP_MSG="build: version bump"
48
49echo "Most recent tag: ${__LAST_TAG}"
50echo "Release version: ${__VERSION}"
51
52_git_log_pretty() {
53  git cliff --config scripts/cliff.toml --unreleased || echo 'git cliff failed'
54}
55
56_do_release_commit() {
57  $__sed -i.bk 's/(NVIM_VERSION_PRERELEASE) "-dev"/\1 ""/' CMakeLists.txt
58  if grep '(NVIM_API_PRERELEASE true)' CMakeLists.txt > /dev/null; then
59    $__sed -i.bk 's/(NVIM_API_PRERELEASE) true/\1 false/' CMakeLists.txt
60    build/bin/nvim --api-info > "test/functional/fixtures/api_level_$__API_LEVEL.mpack"
61    git add "test/functional/fixtures/api_level_${__API_LEVEL}.mpack"
62    make doc
63    git add -u -- runtime/doc/
64  fi
65
66  $__sed -i.bk 's,(<releases>),\1\
67    <release date="'"${__DATE}"'" version="'"${__VERSION}"'"/>,' runtime/org.neovim.nvim.appdata.xml
68  git add runtime/org.neovim.nvim.appdata.xml
69
70  if ! test "$ARG1" = '--use-current-commit' ; then
71    echo "Building changelog since ${__LAST_TAG}..."
72
73    git add CMakeLists.txt
74    (echo "${__RELEASE_MSG}"; _git_log_pretty) | git commit --edit -F -
75  fi
76
77  git tag --sign -a v"${__VERSION}" -m "NVIM v${__VERSION}"
78}
79
80_do_bump_commit() {
81  $__sed -i.bk 's/(NVIM_VERSION_PRERELEASE) ""/\1 "-dev"/' CMakeLists.txt
82  $__sed -i.bk 's/set\((NVIM_VERSION_PATCH) [[:digit:]]/set(\1 ?/' CMakeLists.txt
83  rm -f CMakeLists.txt.bk
84  rm -f runtime/org.neovim.nvim.appdata.xml.bk
85  nvim +'/NVIM_VERSION' +1new +'exe "norm! iUpdate version numbers!!!"' \
86    -O CMakeLists.txt
87
88  git add CMakeLists.txt
89  git commit -m "$__BUMP_MSG"
90}
91
92if ! test "$ARG1" = '--only-bump' ; then
93  _do_release_commit
94fi
95_do_bump_commit
96echo "
97Next steps:
98    - Run tests/CI (version_spec.lua)!
99    - Push the tag:
100        git push origin tag v${__VERSION}
101    - Update website: index.html"