From 9b63087ba842d8e52c0707e372029e6ac98e548d Mon Sep 17 00:00:00 2001 From: Jake Lishman Date: Thu, 10 Nov 2022 01:38:00 +0000 Subject: [PATCH] Add deployment pipeline --- .github/workflows/deploy.yml | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..0dbc8b7 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,60 @@ +name: Deploy Python Package + +on: + push: + tags: + - 'v*' + +jobs: + deploy: + name: Deploy to PyPI + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + # The version checker uses 'importlib.metadata' which is Python 3.10+. + python-version: '3.10' + + - name: Build package + run: | + set -e + python3 -mvenv .venv + source .venv/bin/activate + + pip install -U pip wheel build + python -m build --sdist --wheel + + - name: Verify package + run: | + set -e + source .venv/bin/activate + + pip install ./dist/qiskit_qasm3_import-*.whl + + # Extract the version information from the end of the tag. + tag_version=${GITHUB_REF#refs/tags/v} + # We could get this from the wheel filename too, but it's easier to + # test with Python built-ins. + wheel_version=$(python3 -c 'from importlib.metadata import version; print(version("qiskit_qasm3_import"))') + + if [[ "$tag_version" != "$wheel_version" ]]; then + echo "Version mismatch: tag says '$tag_version', wheel says '$wheel_version'" >&2 + exit 1 + fi + + # Last-ditch validity check that the wheel actually imports. + python3 -c 'import qiskit_qasm3_import' + + - name: Upload to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.JAKELISHMAN_PYPI_TOKEN }} + run: | + set -e + source .venv/bin/activate + + python3 -mpip install -U twine + twine upload ./dist/*.whl ./dist/*.tar.gz