release.sh 3.3 KB

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