|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +if [ -z "$GITHUB_TAG_REF" ]; then |
| 5 | + echo "Not on a tag, won't deploy to pypi" |
| 6 | +elif [ -n "$NO_DEPLOY" ]; then |
| 7 | + echo "Not on a build config, won't deploy to pypi" |
| 8 | +else |
| 9 | + git clean -f -x |
| 10 | + source activate test |
| 11 | + |
| 12 | + if [ "$UNAME" = "linux" ]; then |
| 13 | + conda create --quiet --yes -n wheel python=$PYTHON |
| 14 | + conda activate wheel |
| 15 | + |
| 16 | + docker pull $DOCKER_IMAGE |
| 17 | + pyabis=$(echo $PYABI | tr ":" "\n") |
| 18 | + for abi in $pyabis; do |
| 19 | + git clean -f -x |
| 20 | + docker run --rm -e "PYABI=$abi" -e "GIT_TAG=$GIT_TAG" -v `pwd`:/io \ |
| 21 | + $DOCKER_IMAGE $PRE_CMD /io/.github/workflows/build-wheels.sh |
| 22 | + sudo chown -R $(id -u):$(id -g) ./* |
| 23 | + mv dist/*.whl /tmp |
| 24 | + done |
| 25 | + mv /tmp/*.whl dist/ |
| 26 | + |
| 27 | + conda activate test |
| 28 | + else |
| 29 | + conda create --quiet --yes -n wheel python=$PYTHON |
| 30 | + conda activate wheel |
| 31 | + |
| 32 | + pip wheel --no-deps . |
| 33 | + |
| 34 | + conda activate test |
| 35 | + |
| 36 | + mkdir -p dist |
| 37 | + cp *.whl dist/ |
| 38 | + |
| 39 | + if [[ "$UNAME" == "darwin" ]]; then |
| 40 | + pip install delocate |
| 41 | + delocate-wheel dist/*.whl |
| 42 | + delocate-addplat --rm-orig -x 10_9 -x 10_10 dist/*.whl |
| 43 | + fi |
| 44 | + fi |
| 45 | + |
| 46 | + if [ -n "$BUILD_STATIC" ]; then |
| 47 | + python setup.py sdist --formats=gztar |
| 48 | + fi |
| 49 | + |
| 50 | + echo "" |
| 51 | + echo "Generated files:" |
| 52 | + ls dist/ |
| 53 | + echo "" |
| 54 | + |
| 55 | + if [[ "$GITHUB_REPOSITORY" == "mars-project/shared_memory38" ]]; then |
| 56 | + PYPI_REPO="https://upload.pypi.org/legacy/" |
| 57 | + else |
| 58 | + PYPI_REPO="https://test.pypi.org/legacy/" |
| 59 | + fi |
| 60 | + |
| 61 | + echo "[distutils]" > ~/.pypirc |
| 62 | + echo "index-servers =" >> ~/.pypirc |
| 63 | + echo " pypi" >> ~/.pypirc |
| 64 | + echo "[pypi]" >> ~/.pypirc |
| 65 | + echo "repository=$PYPI_REPO" >> ~/.pypirc |
| 66 | + echo "username=pyodps" >> ~/.pypirc |
| 67 | + echo "password=$PYPI_PWD" >> ~/.pypirc |
| 68 | + |
| 69 | + python -m pip install twine |
| 70 | + python -m twine upload -r pypi --skip-existing dist/* |
| 71 | +fi |
0 commit comments