Skip to content

Commit 37d36e4

Browse files
committed
Add PyPI publish workflow
1 parent 51c5705 commit 37d36e4

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

.github/workflows/publish.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Publish to PyPI / TestPyPI
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*" # triggers on v0.1.0, v0.1.0-test, etc.
7+
8+
jobs:
9+
build-and-publish:
10+
runs-on: ubuntu-24.04
11+
environment: pypi
12+
permissions:
13+
contents: read
14+
id-token: write # required for OIDC / Trusted Publisher
15+
16+
steps:
17+
- name: Check out code
18+
uses: actions/checkout@v4
19+
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: "3.11"
24+
25+
- name: Install Poetry
26+
run: |
27+
curl -sSL https://install.python-poetry.org | python -
28+
echo "$HOME/.local/bin" >> $GITHUB_PATH
29+
30+
- name: Install dependencies
31+
run: |
32+
poetry install --no-root
33+
34+
- name: Build package
35+
run: |
36+
poetry build
37+
38+
# Decide target (PyPI vs TestPyPI) based on tag name
39+
- name: Publish to TestPyPI (tags ending in -test)
40+
if: endsWith(github.ref_name, '-test')
41+
uses: pypa/gh-action-pypi-publish@v1
42+
with:
43+
repository-url: https://test.pypi.org/legacy/
44+
45+
- name: Publish to PyPI (normal version tags)
46+
if: "!endsWith(github.ref_name, '-test')"
47+
uses: pypa/gh-action-pypi-publish@v1
48+
# no repository-url needed; default is https://upload.pypi.org/legacy/

0 commit comments

Comments
 (0)