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
Showing
1 changed file
with
71 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,71 @@ | ||
name: Release | ||
|
||
on: [push] | ||
|
||
# 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, and this workflow to 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: Get tag name | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
shell: bash | ||
run: | | ||
echo ${{ github.ref }} | ||
echo "TAG_NAME=$(echo ${GITHUB_REF##*/} | tr / -)" >> $GITHUB_ENV | ||
cat $GITHUB_ENV | ||
- name: Check that tag is release | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
run: test "v${{ steps.get_version.outputs.VERSION }}" == "${{ env.TAG_NAME }}" | ||
|
||
- 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 | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/master') && ! endsWith(steps.get_version.outputs.VERSION, '-dev') && ! endsWith(steps.get_version.outputs.VERSION, '+dev') | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
repository_url: https://test.pypi.org/legacy/ | ||
|
||
- name: Publish package to PyPI | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} |