Skip to content

Commit c230120

Browse files
luohahaclaude
andcommitted
ci: auto-publish to PyPI on version tag via Trusted Publishing
Push a `v*` tag to build (uv build) and publish to PyPI. Uses OIDC Trusted Publishing — no token stored in the repo. A guard fails the run if the tag does not match the version in pyproject.toml. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CHb1FkoMGfDfwmeJR5hBG6
1 parent 1eb2f43 commit c230120

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release to PyPI
2+
3+
# Push a version tag (e.g. `v0.1.0`) to build and publish to PyPI.
4+
# Auth is PyPI Trusted Publishing (OIDC) — no token/secret in the repo.
5+
# One-time setup: on pypi.org add a publisher for project `goaloop`
6+
# owner: luohaha repo: GoaLoop workflow: release.yml environment: pypi
7+
8+
on:
9+
push:
10+
tags:
11+
- "v*"
12+
13+
jobs:
14+
release:
15+
runs-on: ubuntu-latest
16+
environment:
17+
name: pypi
18+
url: https://pypi.org/p/goaloop
19+
permissions:
20+
id-token: write # mint the OIDC token Trusted Publishing needs
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
27+
- name: Verify tag matches package version
28+
run: |
29+
tag="${GITHUB_REF_NAME#v}"
30+
ver=$(grep -m1 '^version' pyproject.toml | sed -E 's/.*"([^"]+)".*/\1/')
31+
echo "tag=$tag pyproject=$ver"
32+
if [ "$tag" != "$ver" ]; then
33+
echo "::error::tag v$tag does not match pyproject version $ver — bump pyproject.toml first"
34+
exit 1
35+
fi
36+
37+
- name: Build sdist + wheel
38+
run: uv build
39+
40+
- name: Publish to PyPI
41+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)