Skip to content

🔧 chore: switch PyPI release to OIDC trusted publishing#199

Merged
lemonsaurus merged 1 commit into
mainfrom
chore/pypi-trusted-publishing
May 3, 2026
Merged

🔧 chore: switch PyPI release to OIDC trusted publishing#199
lemonsaurus merged 1 commit into
mainfrom
chore/pypi-trusted-publishing

Conversation

@lemonsaurus

@lemonsaurus lemonsaurus commented May 2, 2026

Copy link
Copy Markdown
Owner

Warning

Once a release run succeeds end-to-end, the `PYPI_TOKEN` secret can be deleted from repo settings. Until then, leave it in place as a safety net.

What

Migrates publish.yaml off the long-lived PYPI_TOKEN secret and onto PyPI Trusted Publishing (OIDC). Mirrors the same change in django-simple-bulma#134.

Why

before after
uv publish with UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }} pypa/gh-action-pypi-publish@release/v1 mints a short-lived OIDC token at run time
Token has to be rotated manually if it ever leaks No token to leak; trust is scoped to repo + workflow + environment by PyPI
Two PyPI jobs, two checkouts One release job

The PyPI side is already configured (Trusted Publisher: lemonsaurus / blackbox / publish.yaml / environment pypi).

What changed in the workflow

  • Collapsed bump-pyproject-version and publish-to-pypi into a single release job.
  • Added environment: pypi and permissions: id-token: write (required for OIDC) plus contents: write for the version-bump auto-commit.
  • Build still happens via uv build (inherited from 🪛 chore: modernize linting, CI, and devex tooling #198); pypa/gh-action-pypi-publish reads the resulting dist/.
  • The DockerHub build-and-push-on-release job is untouched. DockerHub credentials don't have an OIDC equivalent we use, so the DOCKERHUB_TOKEN secret stays.

@lemonsaurus lemonsaurus force-pushed the chore/pypi-trusted-publishing branch from 25df4ff to 0d2d60f Compare May 2, 2026 10:57
@lemonsaurus lemonsaurus changed the base branch from main to chore/modernize-tooling May 2, 2026 10:57
@lemonsaurus lemonsaurus force-pushed the chore/pypi-trusted-publishing branch from a4213b8 to 09ab7cf Compare May 3, 2026 07:53
Base automatically changed from chore/modernize-tooling to chore/dep-upgrades May 3, 2026 07:58
Base automatically changed from chore/dep-upgrades to main May 3, 2026 08:07
Stacked on #198 (poetry -> uv migration). Replaces the long-lived
PYPI_TOKEN secret with PyPI Trusted Publishing via
pypa/gh-action-pypi-publish (OIDC).

- Collapse bump-pyproject-version + publish-to-pypi into a single
  release job. No reason to checkout twice now that the version bump,
  build, and publish all live in the same place.
- Add environment: pypi so the publish step is gated by the GitHub
  environment we registered as a trusted publisher on PyPI.
- Add permissions: id-token: write (required for OIDC) and
  contents: write (the auto-commit needs it).
- Drop UV_PUBLISH_TOKEN; pypa/gh-action-pypi-publish reads dist/ and
  uses the OIDC identity directly.

The PYPI_TOKEN secret can be deleted once a release run succeeds.
@lemonsaurus lemonsaurus force-pushed the chore/pypi-trusted-publishing branch from 09ab7cf to f505c36 Compare May 3, 2026 08:09
@lemonsaurus lemonsaurus merged commit d0dcbf5 into main May 3, 2026
6 checks passed
@lemonsaurus lemonsaurus deleted the chore/pypi-trusted-publishing branch May 3, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant