Skip to content

Commit d2af0f6

Browse files
Add PyPI publish workflow.
1 parent a077128 commit d2af0f6

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/publish.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch: # Manual trigger for TestPyPI testing
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
id-token: write # Required for trusted publishing
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.11'
21+
22+
- name: Install build tools
23+
run: pip install build
24+
25+
- name: Build package
26+
run: python -m build
27+
28+
- name: Verify package
29+
run: |
30+
pip install twine
31+
twine check dist/*
32+
33+
# TestPyPI for manual runs or pre-releases
34+
- name: Publish to TestPyPI
35+
if: github.event_name == 'workflow_dispatch' || github.event.release.prerelease
36+
uses: pypa/gh-action-pypi-publish@release/v1
37+
with:
38+
repository-url: https://test.pypi.org/legacy/
39+
40+
# PyPI for full releases only
41+
- name: Publish to PyPI
42+
if: github.event_name == 'release' && !github.event.release.prerelease
43+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)