Skip to content

Publish to PyPI with trusted publishing - #13

Merged
anth-volk merged 2 commits into
masterfrom
trusted-publishing
Oct 12, 2026
Merged

anth-volk merged 2 commits into
masterfrom
trusted-publishing

Conversation

@anth-volk

@anth-volk anth-volk commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
  • make format && make documentation has 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.PYPI token to PyPI trusted publishing (OIDC).

In .github/workflows/push.yaml, the Publish job (the one that runs pypa/gh-action-pypi-publish) now:

  • runs in the pypi environment (environment: pypi)
  • has job-level permissions: contents: write (kept because publish-git-tag.sh pushes a tag; the repo default token is already write) + id-token: write
  • no longer passes user: __token__ / password: ${{ secrets.PYPI }}. The action ignores OIDC while a password is given, so these had to go. skip_existing is kept.

The pypi environment already exists in this repo and is limited to master. This PR does not change any repo settings, environments or secrets. secrets.PYPI is not used anywhere else under .github/.

Merging cuts a patch release via changelog.d/trusted-publishing.changed.md. .github/bump_version.py returns major only for breaking, minor for added/removed, and patch otherwise, so changed gives a patch bump. Running bump_version.py and towncrier build locally on this branch gives 0.2.0 -> 0.2.1.

Existing failures (not fixed here, and they do not block publishing)

In the 2026-04-28 push run, Publish succeeded. Two other jobs failed: Test (ubuntu-latest) at its Deploy documentation step, and Deploy at Update API. Update API fails because .github/update_api.py opens setup.py, which no longer exists after the move to pyproject. The docs deploy step most likely fails because myst build docs does not write docs/_build/html. Its logs have expired, so I could not confirm. Publish does not depend on either job.

Needs a human decision

PyPI already has policyengine-il 0.2.0, uploaded 2026-02-24, above this repo's 0.1.5 line, so a patch release from 0.1.5 would sort below it and pip install policyengine-il would keep installing 0.2.0. This PR therefore sets the base version in pyproject.toml to 0.2.0, so the release is 0.2.1, which becomes the latest. 0.2.1 is not on PyPI.

Before merging

Add a trusted publisher on PyPI (project settings, Publishing) with these values:

Field Value
PyPI project policyengine-il
Owner PolicyEngine
Repository policyengine-il
Workflow filename push.yaml
Environment pypi

If this PR is merged before the publisher is added, the publish step fails with invalid-publisher and that release does not reach PyPI.

Test plan

  • actionlint on .github/workflows/push.yaml: no new findings compared with master.
  • Ran the release step locally on this branch; it computes a patch bump (see above).
  • PR checks pass.
  • After the PyPI publisher is added and this is merged, the Publish job's deployment to pypi uploads the new patch version to https://pypi.org/project/policyengine-il/ with no token.

🤖 Generated with Claude Code

anth-volk and others added 2 commits October 12, 2026 17:35
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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PyPI already has policyengine-il 0.2.0 (uploaded 2026-02-24), above
this repo's version line, so a patch release from the old version
would sort below it and pip would keep installing 0.2.0. Start from
0.2.0 so this release is 0.2.1.

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 15:53
@anth-volk
anth-volk merged commit ba510ab into master Oct 12, 2026
4 checks passed
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