release.sh 3.3 KB

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