Skip to content

Commit 9b369d4

Browse files
committed
feat: add PyPI publishing workflow
- Create GitHub Actions workflow for automated PyPI publishing - Support both TestPyPI and PyPI publishing targets - Add manual workflow dispatch with version input - Configure automatic publishing on release creation - Use uv for dependency management and build tools - Include version update capability for manual releases
1 parent c7496a7 commit 9b369d4

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

.github/workflows/publish.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'Version to publish (e.g., 1.0.0)'
10+
required: true
11+
default: '1.0.0'
12+
publish_to:
13+
description: 'Where to publish'
14+
required: true
15+
default: 'testpypi'
16+
type: choice
17+
options:
18+
- testpypi
19+
- pypi
20+
21+
jobs:
22+
publish:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Install uv
29+
uses: astral-sh/setup-uv@v5
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: "3.11"
35+
36+
- name: Install dependencies
37+
run: |
38+
uv sync
39+
uv pip install build twine
40+
41+
- name: Update version
42+
if: github.event.inputs.version
43+
run: |
44+
# Update version in pyproject.toml
45+
sed -i 's/^version = ".*"/version = "${{ github.event.inputs.version }}"/' pyproject.toml
46+
47+
- name: Build package
48+
run: |
49+
uv run python -m build
50+
51+
- name: Publish to TestPyPI
52+
if: github.event.inputs.publish_to == 'testpypi' || github.event_name == 'release'
53+
env:
54+
TWINE_USERNAME: __token__
55+
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
56+
TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
57+
run: |
58+
uv run twine upload --verbose dist/*
59+
60+
- name: Publish to PyPI
61+
if: github.event.inputs.publish_to == 'pypi'
62+
env:
63+
TWINE_USERNAME: __token__
64+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
65+
run: |
66+
uv run twine upload --verbose dist/*

0 commit comments

Comments
 (0)