Skip to content

Commit

Permalink
Add deployment pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelishman committed Nov 10, 2022
1 parent b333697 commit 9b63087
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9b63087

Please sign in to comment.