make-branch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. #
  3. # Prepare a new release branch
  4. #
  5. . "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
  6. function usage() {
  7. >&2 cat << EOM
  8. Create a new release branch 'release-<version>'
  9. Usage:
  10. $0 <version> [<base_version>]
  11. Options:
  12. version version string for the release (ex: 1.6.0)
  13. base_version branch or tag to start from. Defaults to master. For
  14. bug-fix releases use the previous stage release tag.
  15. EOM
  16. exit 1
  17. }
  18. [ -n "$1" ] || usage
  19. VERSION=$1
  20. BRANCH=bump-$VERSION
  21. REPO=docker/compose
  22. [email protected]:$REPO
  23. if [ -z "$2" ]; then
  24. BASE_VERSION="master"
  25. else
  26. BASE_VERSION=$2
  27. fi
  28. DEFAULT_REMOTE=release
  29. REMOTE="$(find_remote "$GITHUB_REPO")"
  30. # If we don't have a docker remote add one
  31. if [ -z "$REMOTE" ]; then
  32. echo "Creating $DEFAULT_REMOTE remote"
  33. git remote add ${DEFAULT_REMOTE} ${GITHUB_REPO}
  34. fi
  35. # handle the difference between a branch and a tag
  36. if [ -z "$(git name-rev --tags $BASE_VERSION | grep tags)" ]; then
  37. BASE_VERSION=$REMOTE/$BASE_VERSION
  38. fi
  39. echo "Creating a release branch $VERSION from $BASE_VERSION"
  40. read -n1 -r -p "Continue? (ctrl+c to cancel)"
  41. git fetch $REMOTE -p
  42. git checkout -b $BRANCH $BASE_VERSION
  43. echo "Merging remote release branch into new release branch"
  44. git merge --strategy=ours --no-edit $REMOTE/release
  45. # Store the release version for this branch in git, so that other release
  46. # scripts can use it
  47. git config "branch.${BRANCH}.release" $VERSION
  48. echo "Update versions in docs/install.md, compose/__init__.py, script/run.sh"
  49. $EDITOR docs/install.md
  50. $EDITOR compose/__init__.py
  51. $EDITOR script/run.sh
  52. echo "Write release notes in CHANGELOG.md"
  53. browser "https://github.com/docker/compose/issues?q=milestone%3A$VERSION+is%3Aclosed"
  54. $EDITOR CHANGELOG.md
  55. git diff
  56. echo "Verify changes before commit. Exit the shell to commit changes"
  57. $SHELL || true
  58. git commit -a -m "Bump $VERSION" --signoff --no-verify
  59. echo "Push branch to user remote"
  60. GITHUB_USER=$USER
  61. USER_REMOTE="$(find_remote $GITHUB_USER/compose)"
  62. if [ -z "$USER_REMOTE" ]; then
  63. echo "No user remote found for $GITHUB_USER"
  64. read -r -p "Enter the name of your github user: " GITHUB_USER
  65. # assumes there is already a user remote somewhere
  66. USER_REMOTE=$(find_remote $GITHUB_USER/compose)
  67. fi
  68. if [ -z "$USER_REMOTE" ]; then
  69. >&2 echo "No user remote found. You need to 'git push' your branch."
  70. exit 2
  71. fi
  72. git push $USER_REMOTE
  73. browser https://github.com/$REPO/compare/docker:release...$GITHUB_USER:$BRANCH?expand=1