-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Action workflow for release process
This reduces but does not completely eliminate manual work in the release process.
- Loading branch information
Showing
1 changed file
with
54 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,54 @@ | ||
name: Publish to PyPI | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
description: 'New version X.X.X' | ||
required: true | ||
type: string | ||
pypi_instance: | ||
# PyPI has a separate instance which can be used for testing purposes. | ||
description: 'PyPI instance for publishing' | ||
required: true | ||
default: 'PyPI' | ||
type: choice | ||
options: | ||
- 'TestPyPI' | ||
- 'PyPI' | ||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
# Fetch all branches and tags. | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
- name: Set Nextstrain bot as git user | ||
run: | | ||
git config --global user.email "78992647+nextstrain-bot@users.noreply.github.com" | ||
git config --global user.name "Nextstrain bot" | ||
- run: python3 -m pip install --upgrade build twine | ||
- run: devel/release ${{ github.event.inputs.version}} | ||
- run: devel/test | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist/ | ||
- run: git push origin master release tag ${{ github.event.inputs.version}} | ||
- name: 'Publish to TestPyPI' | ||
if: ${{ github.event.inputs.pypi_instance == 'TestPyPI' }} | ||
run: twine upload dist/* | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} | ||
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/ | ||
- name: 'Publish to PyPI' | ||
if: ${{ github.event.inputs.pypi_instance == 'PyPI' }} | ||
run: twine upload dist/* | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
TWINE_REPOSITORY_URL: https://upload.pypi.org/legacy/ |