diff options
Diffstat (limited to 'script/release')
-rwxr-xr-x | script/release/build-binaries | 40 | ||||
-rwxr-xr-x | script/release/cherry-pick-pr | 34 | ||||
-rwxr-xr-x | script/release/contributors | 30 | ||||
-rwxr-xr-x | script/release/download-binaries | 32 | ||||
-rwxr-xr-x | script/release/make-branch | 86 | ||||
-rwxr-xr-x | script/release/push-release | 82 | ||||
-rwxr-xr-x | script/release/rebase-bump-commit | 38 | ||||
-rw-r--r-- | script/release/utils.sh | 23 |
8 files changed, 365 insertions, 0 deletions
diff --git a/script/release/build-binaries b/script/release/build-binaries new file mode 100755 index 00000000..a39b186d --- /dev/null +++ b/script/release/build-binaries @@ -0,0 +1,40 @@ +#!/bin/bash +# +# Build the release binaries +# + +. "$(dirname "${BASH_SOURCE[0]}")/utils.sh" + +function usage() { + >&2 cat << EOM +Build binaries for the release. + +This script requires that 'git config branch.${BRANCH}.release' is set to the +release version for the release branch. + +EOM + exit 1 +} + +BRANCH="$(git rev-parse --abbrev-ref HEAD)" +VERSION="$(git config "branch.${BRANCH}.release")" || usage +REPO=docker/compose + +# Build the binaries +script/clean +script/build/linux + +echo "Building the container distribution" +script/build/image $VERSION + +echo "Building the compose-tests image" +script/build/test-image $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 "Don't forget to download the osx and windows binaries from appveyor/bintray\!" +echo "https://dl.bintray.com/docker-compose/$BRANCH/" +echo "https://ci.appveyor.com/project/docker/compose" +echo diff --git a/script/release/cherry-pick-pr b/script/release/cherry-pick-pr new file mode 100755 index 00000000..f4a5a740 --- /dev/null +++ b/script/release/cherry-pick-pr @@ -0,0 +1,34 @@ +#!/bin/bash +# +# Cherry-pick a PR into the release branch +# + +set -e +set -o pipefail + + +function usage() { + >&2 cat << EOM +Cherry-pick commits from a github pull request. + +Usage: + + $0 <github PR number> +EOM + exit 1 +} + +[ -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 make sure it is available on your \$PATH." + exit 2 +fi + + +REPO=docker/compose +GITHUB=https://github.com/$REPO/pull +PR=$1 +url="$GITHUB/$PR" +hub am -3 $url diff --git a/script/release/contributors b/script/release/contributors new file mode 100755 index 00000000..4657dd80 --- /dev/null +++ b/script/release/contributors @@ -0,0 +1,30 @@ +#!/bin/bash +set -e + + +function usage() { + >&2 cat << EOM +Print the list of github contributors for the release + +Usage: + + $0 <previous release tag> +EOM + exit 1 +} + +[[ -n "$1" ]] || usage +PREV_RELEASE=$1 +BRANCH="$(git rev-parse --abbrev-ref HEAD)" +URL="https://api.github.com/repos/docker/compose/compare" + +contribs=$(curl -sf "$URL/$PREV_RELEASE...$BRANCH" | \ + jq -r '.commits[].author.login' | \ + sort | \ + uniq -c | \ + sort -nr) + +echo "Contributions by user: " +echo "$contribs" +echo +echo "$contribs" | awk '{print "@"$2","}' | xargs diff --git a/script/release/download-binaries b/script/release/download-binaries new file mode 100755 index 00000000..5d01f5f7 --- /dev/null +++ b/script/release/download-binaries @@ -0,0 +1,32 @@ +#!/bin/bash + +function usage() { + >&2 cat << EOM +Download Linux, Mac OS and Windows binaries from remote endpoints + +Usage: + + $0 <version> + +Options: + + version version string for the release (ex: 1.6.0) + +EOM + exit 1 +} + + +[ -n "$1" ] || usage +VERSION=$1 +BASE_BINTRAY_URL=https://dl.bintray.com/docker-compose/bump-$VERSION/ +DESTINATION=binaries-$VERSION +APPVEYOR_URL=https://ci.appveyor.com/api/projects/docker/compose/\ +artifacts/dist%2Fdocker-compose-Windows-x86_64.exe?branch=bump-$VERSION + +mkdir $DESTINATION + + +wget -O $DESTINATION/docker-compose-Darwin-x86_64 $BASE_BINTRAY_URL/docker-compose-Darwin-x86_64 +wget -O $DESTINATION/docker-compose-Linux-x86_64 $BASE_BINTRAY_URL/docker-compose-Linux-x86_64 +wget -O $DESTINATION/docker-compose-Windows-x86_64.exe $APPVEYOR_URL diff --git a/script/release/make-branch b/script/release/make-branch new file mode 100755 index 00000000..b8a0cd31 --- /dev/null +++ b/script/release/make-branch @@ -0,0 +1,86 @@ +#!/bin/bash +# +# Prepare a new release branch +# + +. "$(dirname "${BASH_SOURCE[0]}")/utils.sh" + +function usage() { + >&2 cat << EOM +Create a new release branch 'release-<version>' + +Usage: + + $0 <version> [<base_version>] + +Options: + + version version string for the release (ex: 1.6.0) + base_version branch or tag to start from. Defaults to master. For + bug-fix releases use the previous stage release tag. + +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" +else + BASE_VERSION=$2 +fi + + +DEFAULT_REMOTE=release +REMOTE="$(find_remote "$GITHUB_REPO")" +# If we don't have a docker remote add one +if [ -z "$REMOTE" ]; then + echo "Creating $DEFAULT_REMOTE remote" + git remote add ${DEFAULT_REMOTE} ${GITHUB_REPO} +fi + +# handle the difference between a branch and a tag +if [ -z "$(git name-rev --tags $BASE_VERSION | grep tags)" ]; then + BASE_VERSION=$REMOTE/$BASE_VERSION +fi + +echo "Creating a release branch $VERSION from $BASE_VERSION" +read -n1 -r -p "Continue? (ctrl+c to cancel)" +git fetch $REMOTE -p +git checkout -b $BRANCH $BASE_VERSION + +echo "Merging remote release branch into new release branch" +git merge --strategy=ours --no-edit $REMOTE/release + +# Store the release version for this branch in git, so that other release +# scripts can use it +git config "branch.${BRANCH}.release" $VERSION + + +editor=${EDITOR:-vim} + +echo "Update versions in compose/__init__.py, script/run/run.sh" +$editor compose/__init__.py +$editor script/run/run.sh + + +echo "Write release notes in CHANGELOG.md" +browser "https://github.com/docker/compose/issues?q=milestone%3A$VERSION+is%3Aclosed" +$editor CHANGELOG.md + + +git diff +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 docker remote" +git push $REMOTE +browser https://github.com/$REPO/compare/docker:release...$BRANCH?expand=1 diff --git a/script/release/push-release b/script/release/push-release new file mode 100755 index 00000000..0578aaff --- /dev/null +++ b/script/release/push-release @@ -0,0 +1,82 @@ +#!/bin/bash +# +# Create the official release +# + +. "$(dirname "${BASH_SOURCE[0]}")/utils.sh" + +function usage() { + >&2 cat << EOM +Publish a release by building all artifacts and pushing them. + +This script requires that 'git config branch.${BRANCH}.release' is set to the +release version for the release branch. + +EOM + exit 1 +} + +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 make sure it is available on your \$PATH." + exit 2 +fi + + +if [ -z "$(command -v pandoc 2> /dev/null)" ]; then + >&2 echo "$0 requires http://pandoc.org/" + >&2 echo "Please install it and make 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 + +# Check the build status is green +sha=$(git rev-parse HEAD) +url=$API/$REPO/statuses/$sha +build_status=$(curl -s $url | jq -r '.[0].state') +if [ -n "$SKIP_BUILD_CHECK" ]; then + echo "Skipping build status check..." +elif [[ "$build_status" != "success" ]]; then + >&2 echo "Build status is $build_status, but it should be success." + exit -1 +fi + +echo "Tagging the release as $VERSION" +git tag $VERSION +git push $GITHUB_REPO $VERSION + +echo "Uploading the docker image" +docker push docker/compose:$VERSION + +echo "Uploading the compose-tests image" +docker push docker/compose-tests:latest +docker push docker/compose-tests:$VERSION + +echo "Uploading package to PyPI" +pandoc -f markdown -t rst README.md -o README.rst +sed -i -e 's/logo.png?raw=true/https:\/\/github.com\/docker\/compose\/raw\/master\/logo.png?raw=true/' README.rst +./script/build/write-git-sha +python setup.py sdist bdist_wheel +if [ "$(command -v twine 2> /dev/null)" ]; then + twine upload ./dist/docker-compose-${VERSION/-/}.tar.gz ./dist/docker_compose-${VERSION/-/}-py2.py3-none-any.whl +else + python setup.py upload +fi + +echo "Testing pip package" +deactivate || true +virtualenv venv-test +source venv-test/bin/activate +pip install docker-compose==$VERSION +docker-compose version +deactivate +rm -rf venv-test + +echo "Now publish the github release, and test the downloads." +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 new file mode 100755 index 00000000..3c2ae72b --- /dev/null +++ b/script/release/rebase-bump-commit @@ -0,0 +1,38 @@ +#!/bin/bash +# +# Move the "bump to <version>" commit to the HEAD of the branch +# + +. "$(dirname "${BASH_SOURCE[0]}")/utils.sh" + +function usage() { + >&2 cat << EOM +Move the "bump to <version>" commit to the HEAD of the branch + +This script requires that 'git config branch.${BRANCH}.release' is set to the +release version for the release branch. + +EOM + exit 1 +} + + +BRANCH="$(git rev-parse --abbrev-ref HEAD)" +VERSION="$(git config "branch.${BRANCH}.release")" || usage + + +COMMIT_MSG="Bump $VERSION" +sha="$(git log --grep "$COMMIT_MSG\$" --format="%H")" +if [ -z "$sha" ]; then + >&2 echo "No commit with message \"$COMMIT_MSG\"" + exit 2 +fi +if [[ "$sha" == "$(git rev-parse HEAD)" ]]; then + >&2 echo "Bump commit already at HEAD" + exit 0 +fi + +commits=$(git log --format="%H" "$sha..HEAD" | wc -l | xargs echo) + +git rebase --onto $sha~1 HEAD~$commits $BRANCH +git cherry-pick $sha diff --git a/script/release/utils.sh b/script/release/utils.sh new file mode 100644 index 00000000..321c1fb7 --- /dev/null +++ b/script/release/utils.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# +# Util functions for release scripts +# + +set -e +set -o pipefail + + +function browser() { + local url=$1 + xdg-open $url || open $url +} + + +function find_remote() { + local url=$1 + 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 +} |