Skip to content

ci: publish to PyPI via trusted publishing (OIDC) - #211

Merged
davidhu2000 merged 2 commits into
mainfrom
ci/pypi-trusted-publishing
Nov 20, 2026
Merged

davidhu2000 merged 2 commits into
mainfrom
ci/pypi-trusted-publishing

Conversation

@davidhu2000

@davidhu2000 davidhu2000 commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Why

Publishing used a long-lived PYPI_TOKEN secret. A leaked token could push any version to PyPI until someone revoked it. Trusted publishing replaces it: GitHub issues a short-lived OIDC token per run, and PyPI accepts it only from magichourhq/magic-hour-python running publish.yml. The Node SDK already publishes this way.

What changes

  • The publish job gets id-token: write so it can request the OIDC token.
  • poetry publish --build --password=$PYPI_TOKEN becomes poetry build plus pypa/gh-action-pypi-publish (pinned to v1.14.3 by SHA). Uploads also get PEP 740 attestations by default.
  • The publish job runs on ubuntu-latest instead of Blacksmith. The action treats self-hosted runners as best effort, and the Node SDK's publish job runs on GitHub-hosted runners too. Tests and the release workflow stay on Blacksmith.

Setup / follow-up

  • The trusted publisher is already set up on PyPI (screenshot below): repo magichourhq/magic-hour-python, workflow publish.yml, any environment.
  • After the first release goes out this way, delete the PYPI_TOKEN repo secret and revoke the token on PyPI.

🤖 Generated with Claude Code

PyPI trusted publisher config for magic_hour

davidhu2000 and others added 2 commits November 20, 2026 06:33
Replace the PYPI_TOKEN-based poetry publish with pypa/gh-action-pypi-publish,
which authenticates through GitHub OIDC against the trusted publisher
configured on PyPI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
pypa/gh-action-pypi-publish treats self-hosted runners (Blacksmith) as best
effort. Matches magic-hour-node, whose publish job also runs on ubuntu-latest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@davidhu2000
davidhu2000 merged commit 8b6e0ea into main Nov 20, 2026
5 checks passed
@davidhu2000
davidhu2000 deleted the ci/pypi-trusted-publishing branch November 20, 2026 06:37
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