Skip to content

Commit 40712b6

Browse files
authored
Deployment pipeline (#9)
* Load ANTLR files based on dynamic runtime version * Add missing files * Added deploy-ast.yml * Incorporated a couple of jakelishman PR feedbacks * Added deploy action * Removed testpypi after testing
1 parent 99b6b4d commit 40712b6

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

.github/workflows/deploy-ast.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Deploy Reference Python Package
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
build:
10+
uses: ./.github/workflows/build-ast.yml
11+
12+
deploy:
13+
name: Deploy to PyPI
14+
needs: build
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
# There's deliberately no check-out step here, because we don't want the
19+
# checkout anywhere near us complicating matters; we're just trying to
20+
# ensure that the pre-built wheel works, and its version matches what we
21+
# expect from the tag.
22+
23+
- uses: actions/setup-python@v3
24+
with:
25+
# The version checker uses 'importlib.metadata' which is Python 3.10+.
26+
python-version: '3.10'
27+
28+
- uses: actions/download-artifact@v3
29+
with:
30+
name: openpulse-python-wheel
31+
32+
- uses: actions/download-artifact@v3
33+
with:
34+
name: openpulse-python-sdist
35+
36+
- name: Verify package
37+
run: |
38+
set -e
39+
python3 -mvenv .venv
40+
source .venv/bin/activate
41+
python3 -mpip install -U pip wheel
42+
python3 -mpip install openpulse-*.whl
43+
# Extract the version information from the end of the tag.
44+
tag_version=${GITHUB_REF#refs/tags/v}
45+
# We could get this from the wheel filename too, but it's easier to
46+
# test with Python built-ins.
47+
wheel_version=$(python3 -c 'from importlib.metadata import version; print(version("openpulse"))')
48+
if [[ "$tag_version" != "$wheel_version" ]]; then
49+
echo "Version mismatch: tag says '$tag_version', wheel says '$wheel_version'" >&2
50+
exit 1
51+
fi
52+
# Last-ditch validity check that the wheel actually imports.
53+
python3 -c 'import openpulse'
54+
- name: Upload to PyPI
55+
env:
56+
TWINE_USERNAME: __token__
57+
TWINE_PASSWORD: ${{ secrets.OPENQASM_BOT_PYPI_TOKEN }}
58+
run: |
59+
set -e
60+
source .venv/bin/activate
61+
python3 -mpip install -U twine
62+
twine upload openpulse-*.whl openpulse-*.tar.gz

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,17 @@ Finally, you can change to the `source/openpulse` directory and run:
2626
```
2727
pytest .
2828
```
29+
30+
## Deployment procedure
31+
32+
The deployment is primarily managed by a GitHub Actions pipeline, triggered by a tag of the form `v<version>`.
33+
For example, for package version `0.4.0`, the tag should be `v0.4.0`.
34+
35+
To deploy:
36+
37+
1. create a PR that sets the version number of the package in `__init__.py` to what it should be.
38+
2. once the PR has merged, tag the merge commit (for example, `git fetch origin; git tag -m "Python AST 0.4.0" v0.4.0 origin/main`).
39+
3. push the tag to this repository (for example, `git push origin v0.4.0`).
40+
41+
At this point, the deployment pipeline will take over and deploy the package to PyPI.
42+
You should be able to see the progress [in the Actions tab of this repository](https://github.com/openqasm/openpulse/actions/workflows/deploy-ast.yml).

0 commit comments

Comments
 (0)