Skip to content

Commit 3167a71

Browse files
committed
ci(publish): OIDC trusted publishing + prerelease->TestPyPI routing + twine check
Build once (uv build) and verify with twine check, then publish via OIDC (no stored token): prereleases -> TestPyPI, stable releases -> PyPI.
1 parent 2902a40 commit 3167a71

1 file changed

Lines changed: 44 additions & 8 deletions

File tree

.github/workflows/publish.yml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,56 @@ on:
44
release:
55
types: [published]
66

7+
permissions:
8+
contents: read
9+
710
jobs:
8-
publish:
11+
build:
912
runs-on: ubuntu-latest
10-
environment:
11-
name: pypi
12-
url: https://pypi.org/p/interfaze
13-
permissions:
14-
id-token: write
1513
steps:
1614
- uses: actions/checkout@v4
1715
- uses: astral-sh/setup-uv@v6
1816
with:
1917
python-version: "3.12"
2018
- name: Build sdist + wheel
2119
run: uv build
22-
- name: Publish to PyPI (trusted publishing)
23-
uses: pypa/gh-action-pypi-publish@release/v1
20+
- name: Verify metadata
21+
run: uvx twine check dist/*
22+
- uses: actions/upload-artifact@v4
23+
with:
24+
name: dist
25+
path: dist/
26+
27+
testpypi:
28+
needs: build
29+
if: github.event.release.prerelease == true
30+
runs-on: ubuntu-latest
31+
environment:
32+
name: testpypi
33+
url: https://test.pypi.org/p/interfaze
34+
permissions:
35+
id-token: write
36+
steps:
37+
- uses: actions/download-artifact@v4
38+
with:
39+
name: dist
40+
path: dist/
41+
- uses: pypa/gh-action-pypi-publish@release/v1
42+
with:
43+
repository-url: https://test.pypi.org/legacy/
44+
45+
pypi:
46+
needs: build
47+
if: github.event.release.prerelease == false
48+
runs-on: ubuntu-latest
49+
environment:
50+
name: pypi
51+
url: https://pypi.org/p/interfaze
52+
permissions:
53+
id-token: write
54+
steps:
55+
- uses: actions/download-artifact@v4
56+
with:
57+
name: dist
58+
path: dist/
59+
- uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)