Skip to content

Commit a39ddaf

Browse files
lesnik512claude
andcommitted
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>
1 parent d1d25c2 commit a39ddaf

2 files changed

Lines changed: 7 additions & 4 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ 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)
3637
@test -n "${PYPI_TOKEN:-}" || (echo "PYPI_TOKEN is required; refusing to run outside CI" >&2; exit 1)
3738
rm -rf dist
3839
uv version $GITHUB_REF_NAME
3940
uv build
40-
uv publish --token $PYPI_TOKEN
41+
uv publish
4142

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

0 commit comments

Comments
 (0)