push-release 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. #
  3. # Create the official release
  4. #
  5. . "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
  6. function usage() {
  7. >&2 cat << EOM
  8. Publish a release by building all artifacts and pushing them.
  9. This script requires that 'git config branch.${BRANCH}.release' is set to the
  10. release version for the release branch.
  11. EOM
  12. exit 1
  13. }
  14. BRANCH="$(git rev-parse --abbrev-ref HEAD)"
  15. VERSION="$(git config "branch.${BRANCH}.release")" || usage
  16. if [ -z "$(command -v jq 2> /dev/null)" ]; then
  17. >&2 echo "$0 requires https://stedolan.github.io/jq/"
  18. >&2 echo "Please install it and ake sure it is available on your \$PATH."
  19. exit 2
  20. fi
  21. API=https://api.github.com/repos
  22. REPO=docker/compose
  23. [email protected]:$REPO
  24. # Check the build status is green
  25. sha=$(git rev-parse HEAD)
  26. url=$API/$REPO/statuses/$sha
  27. build_status=$(curl -s $url | jq -r '.[0].state')
  28. if [[ "$build_status" != "success" ]]; then
  29. >&2 echo "Build status is $build_status, but it should be success."
  30. exit -1
  31. fi
  32. echo "Tagging the release as $VERSION"
  33. git tag $VERSION
  34. git push $GITHUB_REPO $VERSION
  35. echo "Uploading sdist to pypi"
  36. python setup.py sdist
  37. echo "Uploading the docker image"
  38. docker push docker/compose:$VERSION
  39. if [ "$(command -v twine 2> /dev/null)" ]; then
  40. twine upload ./dist/docker-compose-${VERSION}.tar.gz
  41. else
  42. python setup.py upload
  43. fi
  44. echo "Testing pip package"
  45. virtualenv venv-test
  46. source venv-test/bin/activate
  47. pip install docker-compose==$VERSION
  48. docker-compose version
  49. deactivate
  50. echo "Now publish the github release, and test the downloads."
  51. echo "Email [email protected] and [email protected] about the new release."