release.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/sh
  2. docker image inspect compose/release-tool > /dev/null
  3. if test $? -ne 0; then
  4. docker build -t compose/release-tool -f $(pwd)/script/release/Dockerfile $(pwd)
  5. fi
  6. if test -z $GITHUB_TOKEN; then
  7. echo "GITHUB_TOKEN environment variable must be set"
  8. exit 1
  9. fi
  10. if test -z $BINTRAY_TOKEN; then
  11. echo "BINTRAY_TOKEN environment variable must be set"
  12. exit 1
  13. fi
  14. if test -z $(python -c "import docker; print(docker.version)" 2>/dev/null); then
  15. echo "This script requires the 'docker' Python package to be installed locally"
  16. exit 1
  17. fi
  18. hub_credentials=$(python -c "from docker import auth; cfg = auth.load_config(); print(auth.encode_header(auth.resolve_authconfig(cfg, 'docker.io')).decode('ascii'))")
  19. docker run -it \
  20. -e GITHUB_TOKEN=$GITHUB_TOKEN \
  21. -e BINTRAY_TOKEN=$BINTRAY_TOKEN \
  22. -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK \
  23. -e HUB_CREDENTIALS=$hub_credentials \
  24. --mount type=bind,source=$(pwd),target=/src \
  25. --mount type=bind,source=$HOME/.gitconfig,target=/root/.gitconfig \
  26. --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
  27. --mount type=bind,source=$HOME/.ssh,target=/root/.ssh \
  28. --mount type=bind,source=/tmp,target=/tmp \
  29. -v $HOME/.pypirc:/root/.pypirc \
  30. compose/release-tool $*