|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +TAG=develop |
| 5 | +if [ "$1" != "" ]; then |
| 6 | + TAG=$1 |
| 7 | +fi |
| 8 | + |
| 9 | +cd $(dirname $(readlink -f $0)) |
| 10 | + |
| 11 | +if ! ../venv/bin/twine -h > /dev/null 2> /dev/null; then |
| 12 | + echo "Did not find twine. Please run ../venv/bin/pip install twine" |
| 13 | + exit 1 |
| 14 | +fi |
| 15 | + |
| 16 | +if [[ -n $(git status -s) ]]; then |
| 17 | + echo "Repository is dirty." |
| 18 | + git status -s |
| 19 | + exit 1 |
| 20 | +fi |
| 21 | + |
| 22 | +if [[ $(git rev-parse --abbrev-ref HEAD) != ${TAG} && $(git describe --exact-match --tags 2>/dev/null) != ${TAG} ]]; then |
| 23 | + echo "Repository is currently not on branch/tag ${TAG}." |
| 24 | + exit 1 |
| 25 | +fi |
| 26 | + |
| 27 | +echo "Building sdist and manylinux wheel" |
| 28 | +sudo rm -rf ./pypi_dist |
| 29 | +docker run --rm -v $(pwd)/..:/problemtools -v $(pwd)/pypi_dist:/dist quay.io/pypa/manylinux_2_28_x86_64 /bin/bash -c " |
| 30 | + yum -y install boost-devel gmp-devel ; |
| 31 | + mkdir /build ; |
| 32 | + cd /build ; |
| 33 | + git config --global --add safe.directory /problemtools/.git ; |
| 34 | + git clone /problemtools ; |
| 35 | + cd problemtools ; |
| 36 | + git checkout ${TAG} ; |
| 37 | + /opt/python/cp311-cp311/bin/python -m build ; |
| 38 | + auditwheel repair dist/problemtools-*.whl ; |
| 39 | + cp dist/*.tar.gz /dist ; |
| 40 | + cp wheelhouse/*.whl /dist" |
| 41 | +sudo chown -R $USER:$USER pypi_dist |
| 42 | + |
| 43 | +../venv/bin/twine check pypi_dist/* |
| 44 | + |
| 45 | +echo "Running verifyproblem from wheel on all examples" |
| 46 | +TEMPDIR=$(mktemp -d) |
| 47 | +python3 -m venv "${TEMPDIR}" |
| 48 | +"${TEMPDIR}/bin/pip" install pypi_dist/problemtools*manylinux*whl |
| 49 | +shopt -s extglob |
| 50 | +if ! "${TEMPDIR}/bin/verifyproblem" ../examples/!(README.md); then |
| 51 | + echo "Running verifyproblem on all examples failed. Please review output above to debug." |
| 52 | + rm -rf "${TEMPDIR}" |
| 53 | + exit 1 |
| 54 | +fi |
| 55 | +rm -rf "${TEMPDIR}" |
| 56 | + |
| 57 | +echo "Sucessfully built packages. If you're happy with them, upload:" |
| 58 | +echo " ../venv/bin/twine upload --verbose pypi_dist/*" |
0 commit comments