Skip to content

Commit 4045cd6

Browse files
committed
ci(testpypi): add OIDC TestPyPI publish workflow
1 parent 56f3ed4 commit 4045cd6

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/test-publish.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release (TestPyPI)
2+
3+
on:
4+
# Manual run for quick testing
5+
workflow_dispatch:
6+
# Optional: run on tags like v0.1.0
7+
push:
8+
tags: ["v*"]
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
id-token: write
15+
contents: read
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.11"
22+
23+
- uses: astral-sh/setup-uv@v3
24+
25+
- name: Install deps
26+
run: uv sync --all-extras --dev
27+
28+
- name: Build dists
29+
run: uv run python -m build
30+
31+
- name: Verify tag matches version (only on tag)
32+
if: startsWith(github.ref, 'refs/tags/')
33+
id: get_tag
34+
shell: bash
35+
run: |
36+
TAG="${GITHUB_REF_NAME#v}"
37+
echo "result_tag=$TAG" >> "$GITHUB_OUTPUT"
38+
python - <<'PY'
39+
import sys, tomllib
40+
with open('pyproject.toml', 'rb') as f:
41+
data = tomllib.load(f)
42+
ver = data['project']['version']
43+
if ver != sys.argv[1]:
44+
print(f"Version {ver} != tag {sys.argv[1]}")
45+
raise SystemExit(1)
46+
PY
47+
"$TAG"
48+
49+
- name: Publish distribution 📦 to TestPyPI (OIDC)
50+
uses: pypa/gh-action-pypi-publish@release/v1
51+
with:
52+
repository-url: https://test.pypi.org/legacy/
53+
verbose: true

0 commit comments

Comments
 (0)