Skip to content

Commit d0722a9

Browse files
lesnik512claude
andauthored
ci: publish to PyPI via Trusted Publishing (OIDC) (#89)
* ci: publish to PyPI via Trusted Publishing (OIDC) Drop the long-lived PYPI_TOKEN secret in favor of OIDC. uv publish auto-detects the GitHub Actions id-token, so the release job grants id-token: write and runs under a `pypi` environment that scopes the PyPI Trusted Publisher. Requires a matching Trusted Publisher on the httpware PyPI project (workflow: release.yml, environment: pypi) before the next tag. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * ci: drop PYPI_TOKEN guard from publish recipe OIDC publishing sets no PYPI_TOKEN, so the guard would abort the run. The GITHUB_REF_NAME check still refuses to run outside CI. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * docs(release): add 0.15.1 notes (Trusted Publishing pipeline) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d1d25c2 commit d0722a9

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ on:
1111
- '[0-9]+.[0-9]+.[0-9]+' # stable: 2.7.2
1212
- '[0-9]+.[0-9]+.[0-9]+[a-z]+[0-9]+' # pre-release: 2.0.0rc1, 4.0.0a2
1313

14-
# Needed for softprops/action-gh-release to create the GitHub Release.
14+
# contents: write -> create the GitHub Release; id-token: write -> OIDC for PyPI Trusted Publishing.
1515
permissions:
1616
contents: write
17+
id-token: write
1718

1819
jobs:
1920
release:
2021
runs-on: ubuntu-latest
22+
environment: pypi # scopes the PyPI Trusted Publisher; hook for approval rules
2123
steps:
2224
- uses: actions/checkout@v6
2325
- uses: extractions/setup-just@v4
@@ -45,9 +47,9 @@ jobs:
4547
# PyPI is irreversible, so it runs FIRST: if it fails the job stops and no
4648
# GitHub Release is created advertising a version that never reached PyPI.
4749
# `just publish` derives the version from $GITHUB_REF_NAME (the tag name).
50+
# Auth via PyPI Trusted Publishing (OIDC); no PYPI_TOKEN. Needs a Trusted
51+
# Publisher on the httpware PyPI project (env: pypi, workflow: release.yml).
4852
- run: just publish
49-
env:
50-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
5153

5254
# Description source: planning/releases/<tag>.md if present (verbatim, no
5355
# auto-changelog appended); otherwise GitHub's generated notes. A tag with

‎Justfile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ test *args:
3131
test-branch:
3232
@just test --cov-branch
3333

34+
# Auth via PyPI Trusted Publishing (OIDC); uv publish auto-detects the CI id-token.
3435
publish:
3536
@test -n "${GITHUB_REF_NAME:-}" || (echo "GITHUB_REF_NAME is required; refusing to run outside CI" >&2; exit 1)
36-
@test -n "${PYPI_TOKEN:-}" || (echo "PYPI_TOKEN is required; refusing to run outside CI" >&2; exit 1)
3737
rm -rf dist
3838
uv version $GITHUB_REF_NAME
3939
uv build
40-
uv publish --token $PYPI_TOKEN
40+
uv publish
4141

4242
# Build the docs site, failing on broken links / nav warnings; CI runs this on every PR.
4343
docs-build:

‎planning/releases/0.15.1.md‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# httpware 0.15.1 — release pipeline on PyPI Trusted Publishing
2+
3+
No library changes. The package is identical to 0.15.0; this release exercises the new publish path end-to-end.
4+
5+
## CI
6+
7+
- Releases now authenticate to PyPI via **Trusted Publishing (OIDC)** instead of a long-lived `PYPI_TOKEN` secret. `uv publish` auto-detects the GitHub Actions id-token; the release job runs under a `pypi` environment that scopes the trusted publisher (#89).
8+
9+
## Downstream
10+
11+
No action required. Nothing about the installed package changes.

0 commit comments

Comments
 (0)