Skip to content

Commit 29a1a71

Browse files
committed
Add PyPI publication workflow
This publishes to Test PyPI on tag and published to public PyPI when a github release is made.
1 parent e71fde6 commit 29a1a71

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/publish.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# This workflow is triggered two ways:
2+
#
3+
# 1. When a tag is created, the workflow will upload the package to
4+
# test.pypi.org.
5+
# 2. When a release is made, the workflow will upload the package to pypi.org.
6+
#
7+
# It is done this way until PyPI has draft reviews, to allow for a two-stage
8+
# upload with a chance for manual intervention before the final publication.
9+
name: Upload package
10+
11+
on:
12+
release:
13+
types: [created]
14+
push:
15+
tags:
16+
- '*'
17+
18+
jobs:
19+
deploy:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v2
23+
- name: Set up Python
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: '3.x'
27+
- name: Install dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install -U tox
31+
- name: Create tox environments
32+
run: |
33+
tox -p -e py,build,release --notest
34+
- name: Run tests
35+
run: |
36+
tox -e py
37+
- name: Build package
38+
run: |
39+
tox -e build
40+
- name: Publish package
41+
env:
42+
TWINE_USERNAME: "__token__"
43+
run: |
44+
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
45+
export TWINE_REPOSITORY_URL="https://test.pypi.org/legacy/"
46+
export TWINE_PASSWORD="${{ secrets.TEST_PYPI_UPLOAD_TOKEN }}"
47+
elif [[ "$GITHUB_EVENT_NAME" == "release" ]]; then
48+
export TWINE_REPOSITORY="pypi"
49+
export TWINE_PASSWORD="${{ secrets.PYPI_UPLOAD_TOKEN }}"
50+
else
51+
echo "Unknown event name: ${GITHUB_EVENT_NAME}"
52+
exit 1
53+
fi
54+
55+
tox -e release

0 commit comments

Comments
 (0)