make-branch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 origin 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 $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. # Store the release version for this branch in git, so that other release
  44. # scripts can use it
  45. git config "branch.${BRANCH}.release" $VERSION
  46. echo "Update versions in docs/install.md, compose/__init__.py, script/run.sh"
  47. $EDITOR docs/install.md
  48. $EDITOR compose/__init__.py
  49. $EDITOR script/run.sh
  50. echo "Write release notes in CHANGELOG.md"
  51. browser "https://github.com/docker/compose/issues?q=milestone%3A$VERSION+is%3Aclosed"
  52. $EDITOR CHANGELOG.md
  53. git diff
  54. echo "Verify changes before commit. Exit the shell to commit changes"
  55. $SHELL || true
  56. git commit -a -m "Bump $VERSION" --signoff --no-verify
  57. echo "Push branch to user remote"
  58. GITHUB_USER=$USER
  59. USER_REMOTE="$(find_remote $GITHUB_USER/compose)"
  60. if [ -z "$USER_REMOTE" ]; then
  61. echo "No user remote found for $GITHUB_USER"
  62. read -r -p "Enter the name of your github user: " GITHUB_USER
  63. # assumes there is already a user remote somewhere
  64. USER_REMOTE=$(find_remote $GITHUB_USER/compose)
  65. fi
  66. if [ -z "$USER_REMOTE" ]; then
  67. >&2 echo "No user remote found. You need to 'git push' your branch."
  68. exit 2
  69. fi
  70. git push $USER_REMOTE
  71. browser https://github.com/$REPO/compare/docker:release...$GITHUB_USER:$BRANCH?expand=1