release.bash 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. # Copyright 2019 The Go Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style
  4. # license that can be found in the LICENSE file.
  5. cd "$(git rev-parse --show-toplevel)"
  6. read -p "What is the next release version (e.g., 'v1.26.0')? " VERSION
  7. SEMVER_REGEX='^v\([0-9]*\)[.]\([0-9]*\)[.]\([0-9]*\)\([.a-zA-Z0-9A-Z-]*\)$'
  8. if ! [[ -z $(echo $VERSION | sed -e "s/$SEMVER_REGEX//") ]]; then
  9. echo; echo "invalid: must be a semver string"; exit 1
  10. fi
  11. VERSION_MAJOR=$(echo $VERSION | sed -e "s/$SEMVER_REGEX/\1/")
  12. VERSION_MINOR=$(echo $VERSION | sed -e "s/$SEMVER_REGEX/\2/")
  13. VERSION_PATCH=$(echo $VERSION | sed -e "s/$SEMVER_REGEX/\3/")
  14. VERSION_PRERELEASE=$(echo $VERSION | sed -e "s/$SEMVER_REGEX/\4/")
  15. if ! [[ "$VERSION_MAJOR" =~ ^1$ ]]; then
  16. echo; echo "invalid: major version must be 1"; exit 1
  17. fi
  18. if ! [[ -z $VERSION_PRERELEASE ]] && ! [[ "$VERSION_PRERELEASE" =~ ^-rc[.][0-9]+$ ]]; then
  19. echo; echo "invalid: pre-release suffix must be empty or '-rc.X'"; exit 1
  20. fi
  21. VERSION_PRERELEASE=${VERSION_PRERELEASE#"-"} # trim possible leading dash
  22. function version_string() {
  23. VERSION_STRING="v${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}"
  24. if ! [[ -z $VERSION_PRERELEASE ]]; then
  25. VERSION_STRING="${VERSION_STRING}-${VERSION_PRERELEASE}"
  26. fi
  27. echo $VERSION_STRING
  28. }
  29. read -p "Were there any changes to the generator that relies on new runtime functionality? " YN
  30. case $YN in
  31. [Yy]* )
  32. read -p " What minor version of the runtime is required now? " GEN_VERSION
  33. if ! [[ "$GEN_VERSION" =~ ^[0-9]+$ ]]; then echo; echo "invalid: must be an integer"; exit 1; fi;;
  34. [Nn]* ) ;;
  35. * ) echo; echo "invalid: must be 'yes' or 'no'"; exit 1;;
  36. esac
  37. read -p "Were there any dropped functionality in the runtime for old generated code? " YN
  38. case $YN in
  39. [Yy]* )
  40. read -p " What minor version of the runtime is required now? " MIN_VERSION
  41. if ! [[ "$MIN_VERSION" =~ ^[0-9]+$ ]]; then echo; echo "invalid: must be an integer"; exit 1; fi;;
  42. [Nn]* ) ;;
  43. * ) echo; echo "invalid: must be 'yes' or 'no'"; exit 1;;
  44. esac
  45. echo
  46. echo "Preparing changes to release $(version_string)."
  47. echo
  48. set -e
  49. # Create a new branch to contain the release changes.
  50. if [[ $(git branch --list release) ]]; then
  51. echo "error: release branch already exists"; exit 1
  52. fi
  53. git change release
  54. git sync
  55. # Create commit for actual release.
  56. sed -i -e "s/\(\s*versionMinor\s*=\s*\)[0-9]*/\1$VERSION_MINOR/" runtime/protoimpl/version.go
  57. sed -i -e "s/\(\s*versionPatch\s*=\s*\)[0-9]*/\1$VERSION_PATCH/" runtime/protoimpl/version.go
  58. sed -i -e "s/\(\s*versionPreRelease\s*=\s*\)\"[^\"]*\"/\1\"$VERSION_PRERELEASE\"/" runtime/protoimpl/version.go
  59. if ! [[ -z $GEN_VERSION ]]; then
  60. sed -i -e "s/\(\s*GenVersion\s*=\s*\)[0-9]*/\1$GEN_VERSION/" runtime/protoimpl/version.go
  61. fi
  62. if ! [[ -z $MIN_VERSION ]]; then
  63. sed -i -e "s/\(\s*MinVersion\s*=\s*\)[0-9]*/\1$MIN_VERSION/" runtime/protoimpl/version.go
  64. fi
  65. git commit -a -m "all: release $(version_string)"
  66. # Build release binaries.
  67. go test -mod=vendor -timeout=60m -count=1 integration_test.go "$@" -buildRelease
  68. # Create commit to start development after release.
  69. VERSION_PRERELEASE="${VERSION_PRERELEASE}.devel" # append ".devel"
  70. VERSION_PRERELEASE="${VERSION_PRERELEASE#"."}" # trim possible leading "."
  71. sed -i -e "s/\(\s*versionPreRelease\s*=\s*\)\"[^\"]*\"/\1\"$VERSION_PRERELEASE\"/" runtime/protoimpl/version.go
  72. git commit -a -m "all: start $(version_string)"
  73. echo
  74. echo "Release changes prepared. Additional steps:"
  75. echo " 1) Submit the changes:"
  76. echo " a. Mail out the changes: git mail HEAD"
  77. echo " b. Request a review on the changes and merge them."
  78. echo " 2) Tag a new release on GitHub:"
  79. echo " a. Write release notes highlighting notable changes."
  80. echo " b. Attach pre-compiled binaries as assets to the release."
  81. echo