make-branch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 docs/install.md, compose/__init__.py, script/run/run.sh"
  50. $editor docs/install.md
  51. $editor compose/__init__.py
  52. $editor script/run/run.sh
  53. echo "Write release notes in CHANGELOG.md"
  54. browser "https://github.com/docker/compose/issues?q=milestone%3A$VERSION+is%3Aclosed"
  55. $editor CHANGELOG.md
  56. git diff
  57. echo "Verify changes before commit. Exit the shell to commit changes"
  58. $SHELL || true
  59. git commit -a -m "Bump $VERSION" --signoff --no-verify
  60. echo "Push branch to user remote"
  61. GITHUB_USER=$USER
  62. USER_REMOTE="$(find_remote $GITHUB_USER/compose)"
  63. if [ -z "$USER_REMOTE" ]; then
  64. echo "$GITHUB_USER/compose not found"
  65. read -r -p "Enter the name of your GitHub fork (username/repo): " GITHUB_REPO
  66. # assumes there is already a user remote somewhere
  67. USER_REMOTE=$(find_remote $GITHUB_REPO)
  68. fi
  69. if [ -z "$USER_REMOTE" ]; then
  70. >&2 echo "No user remote found. You need to 'git push' your branch."
  71. exit 2
  72. fi
  73. git push $USER_REMOTE
  74. browser https://github.com/$REPO/compare/docker:release...$GITHUB_USER:$BRANCH?expand=1