Switch PyPI publish workflow to OIDC trusted publishing#7879
Conversation
…C trusted publishing Agent-Logs-Url: https://github.com/microsoft/CCF/sessions/ae6b3f94-23af-4d89-adae-716929b33a1e Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
|
@copilot what does setting an environment on the job do? Also is there a way to set the write permission at the step level rather than the job? |
Two separate things:
For trusted publishing specifically, it also acts as an additional constraint on the PyPI side: when you register the trusted publisher on PyPI you can pin it to a workflow and an environment name (e.g. Step-level |
|
@copilot add an environment to this workflow, call it pypi - what do I need to do in repo settings? |
Agent-Logs-Url: https://github.com/microsoft/CCF/sessions/5bef9d3b-cd2a-45ab-9b30-b8275f2f5b9e Co-authored-by: achamayou <4016369+achamayou@users.noreply.github.com>
Done in 84b59be — added Repo settings to do:
PyPI side: in the |
Replaces the long-lived
PYPI_TOKENupload in.github/workflows/pypi.ymlwith PyPA's official action using OIDC trusted publishing, per the linked GitHub/PyPI guidance.Changes
pip install twine+twine upload -u __token__ -p ${{ secrets.PYPI_TOKEN }}step in favour ofpypa/gh-action-pypi-publish@release/v1.id-token: writeon the job so GitHub can mint the OIDC token PyPI exchanges for a short-lived API token.dist/(the action's defaultpackages-dir) instead ofpython/.pypifor additional hardening (deployment branch/tag restrictions, optional required reviewers, deployment record).secrets.PYPI_TOKENis no longer referenced and can be removed from repo secrets once trusted publishing is live.Out-of-band setup required
pypi(must match the workflow exactly). Optionally restrict "Deployment branches and tags" to the release tag pattern (e.g.ccf-*) and add required reviewers for a manual gate.ccfproject pointing atmicrosoft/CCF, workflowpypi.yml, and set the Environment name topypi. Both sides must match or token minting will fail.