From 1a2a0dd53ded656cc734f454b016c91f0ee2da10 Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Tue, 22 Sep 2015 10:10:11 -0400 Subject: [PATCH] Fix some bugs in the release scripts Signed-off-by: Daniel Nephin --- project/RELEASE-PROCESS.md | 19 +++++++++------ script/release/build-binaries | 21 ++++++++++++++++ script/release/cherry-pick-pr | 6 +++++ script/release/make-branch | 34 +++++++++++++------------- script/release/push-release | 40 +++++++++++++------------------ script/release/rebase-bump-commit | 7 +++--- script/release/utils.sh | 3 +++ 7 files changed, 78 insertions(+), 52 deletions(-) create mode 100755 script/release/build-binaries diff --git a/project/RELEASE-PROCESS.md b/project/RELEASE-PROCESS.md index c9b7a78cf..810c30974 100644 --- a/project/RELEASE-PROCESS.md +++ b/project/RELEASE-PROCESS.md @@ -7,7 +7,7 @@ Create a branch, update version, and add release notes by running `make-branch` ./script/release/make-branch $VERSION [$BASE_VERSION] -`$BASE_VERSION` will default to master. Use the last version tag for a bug fix +`$BASE_VERSION` will default to master. Use the last version tag for a bug fix release. As part of this script you'll be asked to: @@ -40,15 +40,14 @@ As part of this script you'll be asked to: ## To release a version (whether RC or stable) -Check out the bump branch and run the `push-release` script +Check out the bump branch and run the `build-binary` script git checkout bump-$VERSION - ./script/release/push-release $VERSION + ./script/release/build-binary When prompted test the binaries. - 1. Draft a release from the tag on GitHub (the script will open the window for you) @@ -75,11 +74,17 @@ When prompted test the binaries. 3. Attach the binaries. -4. Publish the release on GitHub. +4. If everything looks good, it's time to push the release. -5. Check that both binaries download (following the install instructions) and run. -6. Email maintainers@dockerproject.org and engineering@docker.com about the new release. + ./script/release/push-release + + +5. Publish the release on GitHub. + +6. Check that both binaries download (following the install instructions) and run. + +7. Email maintainers@dockerproject.org and engineering@docker.com about the new release. ## If it’s a stable release (not an RC) diff --git a/script/release/build-binaries b/script/release/build-binaries new file mode 100755 index 000000000..9f65b45d2 --- /dev/null +++ b/script/release/build-binaries @@ -0,0 +1,21 @@ +#!/bin/bash +# +# Build the release binaries +# + +. "$(dirname "${BASH_SOURCE[0]}")/utils.sh" + +REPO=docker/compose + +# Build the binaries +script/clean +script/build-linux +# TODO: build osx binary +# script/prepare-osx +# script/build-osx +# TODO: build or fetch the windows binary +echo "You need to build the osx/windows binaries, that step is not automated yet." + +echo "Create a github release" +# TODO: script more of this https://developer.github.com/v3/repos/releases/ +browser https://github.com/$REPO/releases/new diff --git a/script/release/cherry-pick-pr b/script/release/cherry-pick-pr index 7062f7aa0..604600872 100755 --- a/script/release/cherry-pick-pr +++ b/script/release/cherry-pick-pr @@ -20,6 +20,12 @@ EOM [ -n "$1" ] || usage +if [ -z "$(command -v hub 2> /dev/null)" ]; then + >&2 echo "$0 requires https://hub.github.com/." + >&2 echo "Please install it and ake sure it is available on your \$PATH." + exit 2 +fi + REPO=docker/compose GITHUB=https://github.com/$REPO/pull diff --git a/script/release/make-branch b/script/release/make-branch index 99f711e16..66ed6bbf3 100755 --- a/script/release/make-branch +++ b/script/release/make-branch @@ -3,17 +3,11 @@ # Prepare a new release branch # -set -e -set -o pipefail - -. script/release/utils.sh - -REPO=git@github.com:docker/compose - +. "$(dirname "${BASH_SOURCE[0]}")/utils.sh" function usage() { >&2 cat << EOM -Create a new release branch `release-` +Create a new release branch 'release-' Usage: @@ -29,9 +23,12 @@ EOM exit 1 } + [ -n "$1" ] || usage VERSION=$1 BRANCH=bump-$VERSION +REPO=docker/compose +GITHUB_REPO=git@github.com:$REPO if [ -z "$2" ]; then BASE_VERSION="master" @@ -41,11 +38,11 @@ fi DEFAULT_REMOTE=release -REMOTE=$(find_remote $REPO) +REMOTE="$(find_remote "$GITHUB_REPO")" # If we don't have a docker origin add one if [ -z "$REMOTE" ]; then echo "Creating $DEFAULT_REMOTE remote" - git remote add ${DEFAULT_REMOTE} ${REPO} + git remote add ${DEFAULT_REMOTE} ${GITHUB_REPO} fi # handle the difference between a branch and a tag @@ -65,7 +62,6 @@ git config "branch.${BRANCH}.release" $VERSION echo "Update versions in docs/install.md and compose/__init__.py" -# TODO: automate this $EDITOR docs/install.md $EDITOR compose/__init__.py @@ -75,22 +71,26 @@ browser "https://github.com/docker/compose/issues?q=milestone%3A$VERSION+is%3Acl $EDITOR CHANGELOG.md -echo "Verify changes before commit. Exit the shell to commit changes" git diff -$SHELL -git commit -a -m "Bump $VERSION" --signoff +echo "Verify changes before commit. Exit the shell to commit changes" +$SHELL || true +git commit -a -m "Bump $VERSION" --signoff --no-verify echo "Push branch to user remote" GITHUB_USER=$USER -USER_REMOTE=$(find_remote $GITHUB_USER/compose) +USER_REMOTE="$(find_remote $GITHUB_USER/compose)" if [ -z "$USER_REMOTE" ]; then echo "No user remote found for $GITHUB_USER" - read -n1 -r -p "Enter the name of your github user: " GITHUB_USER + read -r -p "Enter the name of your github user: " GITHUB_USER # assumes there is already a user remote somewhere USER_REMOTE=$(find_remote $GITHUB_USER/compose) fi +if [ -z "$USER_REMOTE" ]; then + >&2 echo "No user remote found. You need to 'git push' your branch." + exit 2 +fi git push $USER_REMOTE -browser https://github.com/docker/compose/compare/docker:release...$GITHUB_USER:$BRANCH?expand=1 +browser https://github.com/$REPO/compare/docker:release...$GITHUB_USER:$BRANCH?expand=1 diff --git a/script/release/push-release b/script/release/push-release index 276d67c1f..7c4486667 100755 --- a/script/release/push-release +++ b/script/release/push-release @@ -3,10 +3,7 @@ # Create the official release # -set -e -set -o pipefail - -. script/release/utils.sh +. "$(dirname "${BASH_SOURCE[0]}")/utils.sh" function usage() { >&2 cat << EOM @@ -22,6 +19,13 @@ EOM BRANCH="$(git rev-parse --abbrev-ref HEAD)" VERSION="$(git config "branch.${BRANCH}.release")" || usage +if [ -z "$(command -v jq 2> /dev/null)" ]; then + >&2 echo "$0 requires https://stedolan.github.io/jq/" + >&2 echo "Please install it and ake sure it is available on your \$PATH." + exit 2 +fi + + API=https://api.github.com/repos REPO=docker/compose GITHUB_REPO=git@github.com:$REPO @@ -35,30 +39,18 @@ if [[ "$build_status" != "success" ]]; then exit -1 fi - -# Build the binaries and sdists -script/build-linux -# TODO: build osx binary -# script/prepare-osx -# script/build-osx -python setup.py sdist --formats=gztar,zip - - -echo "Test those binaries! Exit the shell to continue." -$SHELL - - echo "Tagging the release as $VERSION" git tag $VERSION git push $GITHUB_REPO $VERSION - -echo "Create a github release" -# TODO: script more of this https://developer.github.com/v3/repos/releases/ -browser https://github.com/$REPO/releases/new - echo "Uploading sdist to pypi" -python setup.py sdist upload +python setup.py sdist + +if [ "$(command -v twine 2> /dev/null)" ]; then + twine upload ./dist/docker-compose-${VERSION}.tar.gz +else + python setup.py upload +fi echo "Testing pip package" virtualenv venv-test @@ -68,4 +60,4 @@ docker-compose version deactivate echo "Now publish the github release, and test the downloads." -echo "Email maintainers@dockerproject.org and engineering@docker.com about the new release. +echo "Email maintainers@dockerproject.org and engineering@docker.com about the new release." diff --git a/script/release/rebase-bump-commit b/script/release/rebase-bump-commit index 732b31944..14ad22a98 100755 --- a/script/release/rebase-bump-commit +++ b/script/release/rebase-bump-commit @@ -3,8 +3,7 @@ # Move the "bump to " commit to the HEAD of the branch # -set -e - +. "$(dirname "${BASH_SOURCE[0]}")/utils.sh" function usage() { >&2 cat << EOM @@ -23,7 +22,7 @@ VERSION="$(git config "branch.${BRANCH}.release")" || usage COMMIT_MSG="Bump $VERSION" -sha=$(git log --grep $COMMIT_MSG --format="%H") +sha="$(git log --grep "$COMMIT_MSG" --format="%H")" if [ -z "$sha" ]; then >&2 echo "No commit with message \"$COMMIT_MSG\"" exit 2 @@ -33,7 +32,7 @@ if [[ "$sha" == "$(git rev-parse HEAD)" ]]; then exit 0 fi -commits=$(git log --format="%H" HEAD..$sha | wc -l) +commits=$(git log --format="%H" "$sha..HEAD" | wc -l) git rebase --onto $sha~1 HEAD~$commits $BRANCH git cherry-pick $sha diff --git a/script/release/utils.sh b/script/release/utils.sh index d64d11618..b4e5a2e6a 100644 --- a/script/release/utils.sh +++ b/script/release/utils.sh @@ -4,6 +4,7 @@ # set -e +set -o pipefail function browser() { @@ -17,4 +18,6 @@ function find_remote() { for remote in $(git remote); do git config --get remote.${remote}.url | grep $url > /dev/null && echo -n $remote done + # Always return true, extra remotes cause it to return false + true }