Repository navigation
Publish to PyPI with trusted publishing - #559
Merged
Merged
Conversation
Add environment: pypi and id-token: write to the job that runs pypa/gh-action-pypi-publish, and drop the user/password inputs that passed the org-wide secrets.PYPI token, so the upload uses OIDC. Add a changed fragment so merging cuts a patch release. Move the two fragments under changelog.d/fixed/ to changelog.d/<name>.fixed.md: bump_version.py only reads files at the top of changelog.d, so it exited with "No changelog fragments found" and has failed the Update versioning job on every push since #550. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
make format && make documentationhas been run. (Not applicable: this PR changes only workflow YAML and changelog files.)What's changed
Moves PyPI publishing from the shared org-wide
secrets.PYPItoken to PyPI trusted publishing (OIDC).In
.github/workflows/push.yaml, thePublishjob (the one that runspypa/gh-action-pypi-publish) now:pypienvironment (environment: pypi)permissions:contents: write(kept becausepublish-git-tag.shpushes a tag; the repo default token is already write) +id-token: writeuser: __token__/password: ${{ secrets.PYPI }}. The action ignores OIDC while a password is given, so these had to go.skip_existingis kept.The
pypienvironment already exists in this repo and is limited tomaster. This PR does not change any repo settings, environments or secrets.secrets.PYPIis not used anywhere else under.github/.Merging cuts a patch release via
changelog.d/trusted-publishing.changed.md..github/bump_version.pyreturns major only forbreaking, minor foradded/removed, and patch otherwise, sochangedgives a patch bump. Runningbump_version.pyandtowncrier buildlocally on this branch gives 0.99.0 -> 0.99.1.Fix for the broken release pipeline
The
Update versioningjob has failed on every push tomastersince #550 (2026-03-18), including the 2026-04-28 run. The reason: #550 and #551 put their fragments underchangelog.d/fixed/.bump_version.pyonly looks at files at the top ofchangelog.d/, so it saw none and exited withNo changelog fragments found. I reproduced this locally onmaster. This PR moves the two fragments tochangelog.d/<name>.fixed.md, the layout towncrier and the PR check suggest. With that, they also go into the 0.99.1 changelog, so the #550 enum fix and the #551 workflow change finally get released. Without the move, the bump would still pass but towncrier would quietly skip those two entries.Not fixed here (it does not block the PyPI upload):
publish-git-tag.shcallspython setup.py --version, but there is nosetup.py, so no tag gets pushed (the|| truehides the error).Before merging
Add a trusted publisher on PyPI (project settings, Publishing) with these values:
policyengine-canadaPolicyEnginepolicyengine-canadapush.yamlpypiIf this PR is merged before the publisher is added, the publish step fails with
invalid-publisherand that release does not reach PyPI.Test plan
actionlinton.github/workflows/push.yaml: no new findings compared withmaster.Publishjob's deployment topypiuploads the new patch version to https://pypi.org/project/policyengine-canada/ with no token.🤖 Generated with Claude Code