-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b333697
commit 9b63087
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |