release.sh 3.1 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. FEATURES:
  40. FIXES:
  41. CHANGES:
  42. "
  43. __BUMP_MSG="version bump"
  44. echo "Most recent tag: ${__LAST_TAG}"
  45. echo "Release version: ${__VERSION}"
  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. fi
  53. $__sed -i.bk 's,(<releases>),\1\
  54. <release date="'"${__DATE}"'" version="'"${__VERSION}"'"/>,' runtime/nvim.appdata.xml
  55. git add runtime/nvim.appdata.xml
  56. if ! test "$ARG1" = '--use-current-commit' ; then
  57. echo "Building changelog since ${__LAST_TAG}..."
  58. git add CMakeLists.txt
  59. (echo "${__RELEASE_MSG}"; ./scripts/git-log-pretty-since.sh "$__LAST_TAG" 'vim-patch:[^[:space:]]') | git commit --edit -F -
  60. fi
  61. git tag --sign -a v"${__VERSION}" -m "NVIM v${__VERSION}"
  62. }
  63. _do_bump_commit() {
  64. $__sed -i.bk 's/(NVIM_VERSION_PRERELEASE) ""/\1 "-dev"/' CMakeLists.txt
  65. $__sed -i.bk 's/set\((NVIM_VERSION_PATCH) [[:digit:]]/set(\1 ?/' CMakeLists.txt
  66. rm -f CMakeLists.txt.bk
  67. rm -f runtime/nvim.appdata.xml.bk
  68. nvim +'/NVIM_VERSION' +1new +'exe "norm! iUpdate version numbers!!!"' \
  69. -O CMakeLists.txt
  70. git add CMakeLists.txt
  71. git commit -m "$__BUMP_MSG"
  72. }
  73. if ! test "$ARG1" = '--only-bump' ; then
  74. _do_release_commit
  75. fi
  76. _do_bump_commit
  77. echo "
  78. Next steps:
  79. - Run tests/CI (version_spec.lua)!
  80. - Push the tag:
  81. git push --follow-tags
  82. - Update website: index.html"