push-release 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. if [ -z "$(command -v pandoc 2> /dev/null)" ]; then
  22. >&2 echo "$0 requires http://pandoc.org/"
  23. >&2 echo "Please install it and make sure it is available on your \$PATH."
  24. exit 2
  25. fi
  26. API=https://api.github.com/repos
  27. REPO=docker/compose
  28. [email protected]:$REPO
  29. # Check the build status is green
  30. sha=$(git rev-parse HEAD)
  31. url=$API/$REPO/statuses/$sha
  32. build_status=$(curl -s $url | jq -r '.[0].state')
  33. if [ -n "$SKIP_BUILD_CHECK" ]; then
  34. echo "Skipping build status check..."
  35. elif [[ "$build_status" != "success" ]]; then
  36. >&2 echo "Build status is $build_status, but it should be success."
  37. exit -1
  38. fi
  39. echo "Tagging the release as $VERSION"
  40. git tag $VERSION
  41. git push $GITHUB_REPO $VERSION
  42. echo "Uploading the docker image"
  43. docker push docker/compose:$VERSION
  44. echo "Uploading the compose-tests image"
  45. docker push docker/compose-tests:latest
  46. docker push docker/compose-tests:$VERSION
  47. echo "Uploading package to PyPI"
  48. pandoc -f markdown -t rst README.md -o README.rst
  49. sed -i -e 's/logo.png?raw=true/https:\/\/github.com\/docker\/compose\/raw\/master\/logo.png?raw=true/' README.rst
  50. ./script/build/write-git-sha
  51. python setup.py sdist bdist_wheel
  52. if [ "$(command -v twine 2> /dev/null)" ]; then
  53. twine upload ./dist/docker-compose-${VERSION/-/}.tar.gz ./dist/docker_compose-${VERSION/-/}-py2.py3-none-any.whl
  54. else
  55. python setup.py upload
  56. fi
  57. echo "Testing pip package"
  58. deactivate || true
  59. virtualenv venv-test
  60. source venv-test/bin/activate
  61. pip install docker-compose==$VERSION
  62. docker-compose version
  63. deactivate
  64. rm -rf venv-test
  65. echo "Now publish the github release, and test the downloads."
  66. echo "Email [email protected] and [email protected] about the new release."