release.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. # - Tag the commit.
  15. # Create the "version bump" commit:
  16. # - CMakeLists.txt: Set NVIM_VERSION_PRERELEASE to "-dev"
  17. set -e
  18. set -u
  19. set -o pipefail
  20. ARG1=${1:-no}
  21. __sed=$( [ "$(uname)" = Darwin ] && echo 'sed -E' || echo 'sed -r' )
  22. cd "$(git rev-parse --show-toplevel)"
  23. __LAST_TAG=$(git describe --abbrev=0)
  24. [ -z "$__LAST_TAG" ] && { echo 'ERROR: no tag found'; exit 1; }
  25. __VERSION_MAJOR=$(grep 'set(NVIM_VERSION_MAJOR' CMakeLists.txt\
  26. |$__sed 's/.*NVIM_VERSION_MAJOR ([[:digit:]]).*/\1/')
  27. __VERSION_MINOR=$(grep 'set(NVIM_VERSION_MINOR' CMakeLists.txt\
  28. |$__sed 's/.*NVIM_VERSION_MINOR ([[:digit:]]).*/\1/')
  29. __VERSION_PATCH=$(grep 'set(NVIM_VERSION_PATCH' CMakeLists.txt\
  30. |$__sed 's/.*NVIM_VERSION_PATCH ([[:digit:]]).*/\1/')
  31. __VERSION="${__VERSION_MAJOR}.${__VERSION_MINOR}.${__VERSION_PATCH}"
  32. __API_LEVEL=$(grep 'set(NVIM_API_LEVEL ' CMakeLists.txt\
  33. |$__sed 's/.*NVIM_API_LEVEL ([[:digit:]]).*/\1/')
  34. { [ -z "$__VERSION_MAJOR" ] || [ -z "$__VERSION_MINOR" ] || [ -z "$__VERSION_PATCH" ]; } \
  35. && { echo "ERROR: version parse failed: '${__VERSION}'"; exit 1; }
  36. __RELEASE_MSG="NVIM v${__VERSION}
  37. FEATURES:
  38. FIXES:
  39. CHANGES:
  40. "
  41. __BUMP_MSG="version bump"
  42. echo "Most recent tag: ${__LAST_TAG}"
  43. echo "Release version: ${__VERSION}"
  44. _do_release_commit() {
  45. $__sed -i.bk 's/(NVIM_VERSION_PRERELEASE) "-dev"/\1 ""/' CMakeLists.txt
  46. if grep '(NVIM_API_PRERELEASE true)' CMakeLists.txt > /dev/null; then
  47. $__sed -i.bk 's/(NVIM_API_PRERELEASE) true/\1 false/' CMakeLists.txt
  48. build/bin/nvim --api-info > test/functional/fixtures/api_level_$__API_LEVEL.mpack
  49. git add test/functional/fixtures/api_level_$__API_LEVEL.mpack
  50. fi
  51. if ! test "$ARG1" = '--use-current-commit' ; then
  52. echo "Building changelog since ${__LAST_TAG}..."
  53. __CHANGELOG="$(./scripts/git-log-pretty-since.sh "$__LAST_TAG" 'vim-patch:[^[:space:]]')"
  54. git add CMakeLists.txt
  55. git commit --edit -m "${__RELEASE_MSG} ${__CHANGELOG}"
  56. fi
  57. git tag --sign -a v"${__VERSION}" -m "NVIM v${__VERSION}"
  58. }
  59. _do_bump_commit() {
  60. $__sed -i.bk 's/(NVIM_VERSION_PRERELEASE) ""/\1 "-dev"/' CMakeLists.txt
  61. $__sed -i.bk 's/set\((NVIM_VERSION_PATCH) [[:digit:]]/set(\1 ?/' CMakeLists.txt
  62. nvim +'/NVIM_VERSION' +10new +'exe "norm! iUpdate version numbers!!!\<CR>"' \
  63. +'norm! 10.' CMakeLists.txt
  64. git add CMakeLists.txt
  65. git commit -m "$__BUMP_MSG"
  66. rm CMakeLists.txt.bk || true
  67. }
  68. if ! test "$ARG1" = '--only-bump' ; then
  69. _do_release_commit
  70. fi
  71. _do_bump_commit
  72. echo "
  73. Next steps:
  74. - Double-check NVIM_VERSION_* in CMakeLists.txt
  75. - Push the tag:
  76. git push --follow-tags
  77. - Update the 'stable' tag:
  78. git push --force upstream HEAD^:refs/tags/stable
  79. git fetch --tags
  80. - Update website: index.html"