Skip to content

Commit

Permalink
Add workflow for pushing to PyPI
Browse files Browse the repository at this point in the history
  • Loading branch information
goerz committed Dec 30, 2020
1 parent 79dd45c commit 58dd5f6
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,63 @@
name: Release

on: [push, release]

# Releases work as follows (driven by ./scripts/release.py):
#
# 1. A non-tagged version with a relase `__version__` (anything not ending in
# `+dev` or `-dev`) is pushed to `master`. Since we always add the `+dev`
# suffix after a release, there will only ever be one such commit per
# release. This commit should trigger a release to Test-PyPI, in this
# workflow.
#
# 2. Once the workflows for the release commit pass, the commit is tagged as
# `v<__version__>` and the tag is pushed to Github. This triggers the
# automatic creation of an official "Release" on Github.
#
# 3. The automatic creation of the Release triggers this workflow again,
# causing a release to the regular PyPI
#

jobs:

push_release_to_pypi:
name: Push Package Release to PyPI
runs-on: ubuntu-18.04
steps:

- uses: actions/checkout@v2

- uses: actions/setup-python@v2
name: Install Python 3.8
with:
python-version: 3.8

- name: Install Prerequisites
run: pip install wheel twine

- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::$(python -c 'print([line.split("=")[-1].strip()[1:-1] for line in open("./src/qalgebra/__init__.py", encoding="utf8").readlines() if line.startswith("__version__")][0], end="")')

- name: Build Source and Wheel Package
run: |
python setup.py sdist
python setup.py bdist_wheel
- name: Check distribution files
run: twine check dist/*

- name: Publish package to Test - PyPI (TODO)
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads') && ! endsWith(steps.get_version.outputs.VERSION, "-dev") && ! endsWith(steps.get_version.outputs.VERSION, "+dev")
# TODO: restrict to master
run: |
echo "This is a non-dev release which should be pushed to Test-PyPI"
- name: Publish package to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@master
# TODO: switch to regular PyPI
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

0 comments on commit 58dd5f6

Please sign in to comment.