push-release 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 make 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 [ -n "$SKIP_BUILD_CHECK" ]; then
  29. echo "Skipping build status check..."
  30. elif [[ "$build_status" != "success" ]]; then
  31. >&2 echo "Build status is $build_status, but it should be success."
  32. exit -1
  33. fi
  34. echo "Tagging the release as $VERSION"
  35. git tag $VERSION
  36. git push $GITHUB_REPO $VERSION
  37. echo "Uploading the docker image"
  38. docker push docker/compose:$VERSION
  39. echo "Uploading the compose-tests image"
  40. docker push docker/compose-tests:latest
  41. docker push docker/compose-tests:$VERSION
  42. echo "Uploading package to PyPI"
  43. ./script/build/write-git-sha
  44. python setup.py sdist bdist_wheel
  45. if [ "$(command -v twine 2> /dev/null)" ]; then
  46. twine upload ./dist/docker-compose-${VERSION/-/}.tar.gz ./dist/docker_compose-${VERSION/-/}-py2.py3-none-any.whl
  47. else
  48. python setup.py upload
  49. fi
  50. echo "Testing pip package"
  51. deactivate || true
  52. virtualenv venv-test
  53. source venv-test/bin/activate
  54. pip install docker-compose==$VERSION
  55. docker-compose version
  56. deactivate
  57. rm -rf venv-test
  58. echo "Now publish the github release, and test the downloads."
  59. echo "Email [email protected] and [email protected] about the new release."