make-branch 2.2 KB

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