Skip to content

Commit

Permalink
Deployment pipeline (#9)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
aspcompiler authored Oct 18, 2022
1 parent 99b6b4d commit 40712b6
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/deploy-ast.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Deploy Reference Python Package

on:
push:
tags:
- 'v*'

jobs:
build:
uses: ./.github/workflows/build-ast.yml

deploy:
name: Deploy to PyPI
needs: build
runs-on: ubuntu-latest

steps:
# There's deliberately no check-out step here, because we don't want the
# checkout anywhere near us complicating matters; we're just trying to
# ensure that the pre-built wheel works, and its version matches what we
# expect from the tag.

- uses: actions/setup-python@v3
with:
# The version checker uses 'importlib.metadata' which is Python 3.10+.
python-version: '3.10'

- uses: actions/download-artifact@v3
with:
name: openpulse-python-wheel

- uses: actions/download-artifact@v3
with:
name: openpulse-python-sdist

- name: Verify package
run: |
set -e
python3 -mvenv .venv
source .venv/bin/activate
python3 -mpip install -U pip wheel
python3 -mpip install openpulse-*.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("openpulse"))')
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 openpulse'
- name: Upload to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.OPENQASM_BOT_PYPI_TOKEN }}
run: |
set -e
source .venv/bin/activate
python3 -mpip install -U twine
twine upload openpulse-*.whl openpulse-*.tar.gz
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,17 @@ Finally, you can change to the `source/openpulse` directory and run:
```
pytest .
```

## Deployment procedure

The deployment is primarily managed by a GitHub Actions pipeline, triggered by a tag of the form `v<version>`.
For example, for package version `0.4.0`, the tag should be `v0.4.0`.

To deploy:

1. create a PR that sets the version number of the package in `__init__.py` to what it should be.
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`).
3. push the tag to this repository (for example, `git push origin v0.4.0`).

At this point, the deployment pipeline will take over and deploy the package to PyPI.
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 comments on commit 40712b6

Please sign in to comment.