Skip to content

Publish to PyPI with trusted publishing - #610

Merged
anth-volk merged 1 commit into
masterfrom
trusted-publishing
Oct 12, 2026
Merged

anth-volk merged 1 commit into
masterfrom
trusted-publishing

Conversation

@anth-volk

Copy link
Copy Markdown
Collaborator

What and why

The organisation-wide PYPI secret (created 2021) is readable by every PolicyEngine repository's workflows. This moves policyengine-core to PyPI trusted publishing: PyPI accepts uploads only from this repository's push.yaml workflow running in the pypi environment, using a short-lived OIDC token, so no PyPI credential is stored here.

  • The Publish job in .github/workflows/push.yaml now runs in environment: pypi and adds id-token: write next to its existing contents: write (still needed for the git tag step).
  • user: __token__ and password: ${{ secrets.PYPI }} are removed from pypa/gh-action-pypi-publish. While a password is passed, the action uses it rather than trusted publishing.
  • changelog.d/trusted-publishing.changed.md makes merging cut a patch release, which tests the new publishing path end to end.

The pypi environment already exists in this repository and is limited to the master branch.

Before merging (draft until this is done)

A PyPI owner of policyengine-core adds the publisher under Manage → Publishing → GitHub:

Field Value
Owner PolicyEngine
Repository policyengine-core
Workflow push.yaml
Environment pypi

If this merges first, the release fails with invalid-publisher until the publisher is added; then re-run the job.

Test plan

  • actionlint on the changed workflow (no new findings)
  • PyPI trusted publisher configured
  • After merge: the patch release's Publish job succeeds and the new files on PyPI show provenance from PolicyEngine/policyengine-core / push.yaml

🤖 Generated with Claude Code

Replace the organisation-wide PYPI token with PyPI trusted publishing
(OIDC) in the publish job, which now runs in the pypi environment
limited to master. Adds a changelog fragment so merging cuts a patch
release that verifies the new path end to end.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk marked this pull request as ready for review October 12, 2026 13:46
@anth-volk
anth-volk requested a review from MaxGhenis October 12, 2026 13:46
@anth-volk
anth-volk merged commit 4ff036d into master Oct 12, 2026
19 checks passed
@anth-volk
anth-volk deleted the trusted-publishing branch October 12, 2026 18:59
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