neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

release.sh (3306B)


      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/nvim.appdata.xml
     16 #     - Tag the commit.
     17 #   Create the "version bump" commit:
     18 #     - CMakeLists.txt: Set NVIM_VERSION_PRERELEASE to "-dev"
     19 
     20 set -e
     21 set -u
     22 set -o pipefail
     23 
     24 ARG1=${1:-no}
     25 
     26 __sed=$( [ "$(uname)" = Darwin ] && echo 'sed -E' || echo 'sed -r' )
     27 
     28 cd "$(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="version bump"
     48 
     49 echo "Most recent tag: ${__LAST_TAG}"
     50 echo "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/nvim.appdata.xml
     68  git add runtime/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/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 
     92 if ! test "$ARG1" = '--only-bump' ; then
     93  _do_release_commit
     94 fi
     95 _do_bump_commit
     96 echo "
     97 Next steps:
     98    - Run tests/CI (version_spec.lua)!
     99    - Push the tag:
    100        git push origin tag v${__VERSION}
    101    - Update website: index.html"