| 1 | #! /bin/sh |
| 2 | set -e |
| 3 | |
| 4 | case "$TOXENV" in |
| 5 | pypy*) exit 0 ;; |
| 6 | esac |
| 7 | |
| 8 | umask 022 |
| 9 | chmod -R a+rX . |
| 10 | |
| 11 | py=$(python -c "import sys; print('.'.join(sys.version.split('.')[:2]))") |
| 12 | v=$(echo "$py" | sed 's/\.//') |
| 13 | |
| 14 | pip install -U pip setuptools readme-renderer twine wheel |
| 15 | python setup.py sdist |
| 16 | if [ -f dist/CT3-*.tar.gz ]; then |
| 17 | # Rename sdist to lowercase; different build tools produce different case. |
| 18 | # This is important because stupid PyPI doesn't ignore sdists |
| 19 | # in different cases but also doesn't allow uploading. |
| 20 | # So we use single case, all lower. Also see PEP 625. |
| 21 | cd dist |
| 22 | mv CT3-*.tar.gz "`echo CT3-*.tar.gz | sed 's/^CT3-/ct3-/'`" |
| 23 | cd .. |
| 24 | fi |
| 25 | |
| 26 | if [ -d build ]; then find build -name '*.py[co]' -delete; fi |
| 27 | python setup.py build_ext |
| 28 | python setup.py build --executable '/usr/bin/env python' |
| 29 | python -m compileall build |
| 30 | python -O -m compileall build |
| 31 | python setup.py bdist_wheel |
| 32 | |
| 33 | if [ "$RUNNER_OS" = 'Linux' ]; then |
| 34 | # auditwheel 5.2+ require patchelf 0.14+ |
| 35 | if [ "$py" = 2.7 ]; then |
| 36 | pip3.7 install -U "auditwheel<5.2" |
| 37 | elif [ "$py" = 3.4 ]; then |
| 38 | pip install -U typing "auditwheel==2.1.1" |
| 39 | else |
| 40 | pip install -U "auditwheel<5.2" |
| 41 | fi |
| 42 | |
| 43 | for f in dist/CT3-*-cp"$v"-*-linux*.whl; do |
| 44 | if [ "$py" = 2.7 ]; then |
| 45 | python3.7 -m auditwheel repair -w dist/ "$f" |
| 46 | else |
| 47 | python -m auditwheel repair -w dist/ "$f" |
| 48 | fi |
| 49 | rm -f "$f" |
| 50 | done |
| 51 | |
| 52 | elif [ "$RUNNER_OS" = 'macOS' ]; then |
| 53 | |
| 54 | pip install -U delocate |
| 55 | for f in dist/CT3-*-cp"$v"-*-macosx*.whl; do |
| 56 | delocate-wheel -v "$f" |
| 57 | done |
| 58 | fi |
| 59 | |
| 60 | # TWINE_USERNAME / TWINE_PASSWORD / TWINE_REPOSITORY_URL |
| 61 | # must be set in Github Actions settings. |
| 62 | exec twine upload --disable-progress-bar --skip-existing dist/* |