Skip to content

Commit 2575c52

Browse files
committed
Add GH Action for automatic publishing to PyPI
1 parent 44bd6a8 commit 2575c52

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

.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+
push:
5+
tags:
6+
- '*.*.*' # Triggers on version tags like 2.4.0, 1.0.0, etc.
7+
8+
jobs:
9+
build-and-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+
with:
17+
fetch-depth: 0 # Fetch full history for setuptools_scm
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: '3.12'
23+
24+
- name: Install build dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install build setuptools_scm[toml]
28+
29+
- name: Build package
30+
run: python -m build
31+
32+
- name: Publish to PyPI
33+
uses: pypa/gh-action-pypi-publish@release/v1
34+
with:
35+
# Using trusted publishing (recommended)
36+
# No API token needed if trusted publishing is configured
37+
# Otherwise, add PYPI_API_TOKEN to repository secrets
38+
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)