How to set up OIDC trusted publishing per registry. Once configured, the CI workflow exchanges an ephemeral ID token at publish time; no long-lived tokens sit in the secret store.
- A CI runner that issues OIDC ID tokens (GitHub Actions, GitLab
CI with
id_tokens, CircleCI, Buildkite, etc.). - A repo with a permission grant equivalent to GitHub Actions'
permissions: { id-token: write }.
- Log into https://pypi.org/manage/account/publishing/.
- Add a new "trusted publisher" entry:
- Owner:
my-org - Repository:
my-package - Workflow filename:
release.yml - Environment: leave blank or use
pypiif you've protected the environment in GitHub.
- Owner:
- Save.
Workflow snippet:
permissions:
id-token: write
jobs:
release:
runs-on: ubuntu-latest
environment: pypi # optional but recommended
steps:
- run: release-kit publish --target pypi --applyFull reference: playbook/registries/pypi.md.
- https://docs.npmjs.com/trusted-publishers walks the registry-side setup.
- The package's
package.jsonmust include apublishConfigblock withprovenance: true. - Workflow needs
id-token: write+ Node 22+.
Workflow snippet:
- run: npm publish --provenance --access public…or via release-kit:
- run: release-kit publish --target npm --applyGHCR uses the workflow's GITHUB_TOKEN; no extra OIDC dance.
Workflow needs packages: write.
permissions:
packages: write
- run: release-kit publish --target ghcr --applyhttps://guides.rubygems.org/trusted-publishing/ is the authoritative guide. Set up a trusted publisher pointing at the repo + workflow. Then:
permissions:
id-token: write
- run: release-kit publish --target rubygems --apply- Create an IAM identity provider for
token.actions.githubusercontent.comin AWS. - Create an IAM role with
ecr:PutImage,ecr:BatchCheckLayer…,ecr:InitiateLayerUpload, etc., trusted by the OIDC provider scoped torepo:my-org/my-package:ref:refs/tags/v*. - Workflow uses
aws-actions/configure-aws-credentials:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::123456789012:role/release-kit-pusher
aws-region: us-east-1
- run: release-kit publish --target aws-ecr --applyRun release-kit doctor from within the CI workflow itself; the
auth column will show OIDC for trusted-publish targets if the ID
token resolved. If it falls back to TOKEN, the workflow's
permissions are wrong.
A common failure: forgetting id-token: write at the workflow
level. Setting it on a single job is not enough if a step expects
the env var to be present earlier.
Set policies.allow_token_auth = false (the default) to refuse
silent fallback to a long-lived token when OIDC fails. Override on a
per-run basis with --allow-token-auth when you need to.