make-branch 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. editor=${EDITOR:-vim}
  49. echo "Update versions in compose/__init__.py, script/run/run.sh"
  50. $editor compose/__init__.py
  51. $editor script/run/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 docker remote"
  60. git push $REMOTE
  61. browser https://github.com/$REPO/compare/docker:release...$BRANCH?expand=1