Skip to content

Commit 71be8a4

Browse files
committed
feat(ci): workflow publishes to PyPI on release
* publish to TestPyPI for prerelease * publish to regular PyPI for non-prerelease
1 parent 0c5c2f6 commit 71be8a4

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

.github/workflows/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.10

.github/workflows/publish.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
jobs:
9+
publish:
10+
name: Publish to PyPI
11+
runs-on: ubuntu-latest
12+
if: "startsWith(github.event.release.tag_name, 'v')"
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- uses: actions/setup-python@v3
17+
with:
18+
python-version-file: .github/workflows/.python-version
19+
20+
- name: Install build dependencies
21+
run: pip install build
22+
23+
- name: Build package
24+
run: python -m build
25+
26+
- name: Publish to Test PyPI
27+
uses: pypa/gh-action-pypi-publish@release/v1.5
28+
if: "github.event.release.prerelease"
29+
with:
30+
username: __token__
31+
password: ${{ secrets.PYPI_TEST_API_TOKEN }}
32+
33+
- name: Publish to PyPI
34+
uses: pypa/gh-action-pypi-publish@release/v1.5
35+
if: "!github.event.release.prerelease"
36+
with:
37+
username: __token__
38+
password: ${{ secrets.PYPI_API_TOKEN }}

.github/workflows/tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ jobs:
1414

1515
steps:
1616
- uses: actions/checkout@v3
17+
1718
- name: Set up Python ${{ matrix.python-version }}
1819
uses: actions/setup-python@v3
1920
with:
2021
python-version: ${{ matrix.python-version }}
22+
2123
- name: Install dependencies
2224
run: |
2325
python -m pip install --upgrade pip
2426
pip install -r tests/requirements.txt
2527
pip install -e .
28+
2629
- name: Run tests
2730
run: ./tests/run.sh

0 commit comments

Comments
 (0)