Skip to content

ci: publish to npm and PyPI via trusted publishing (OIDC) instead of tokens - #85

Merged
hoegertn merged 1 commit into
mainfrom
feat/trusted-publishing
Oct 10, 2026
Merged

hoegertn merged 1 commit into
mainfrom
feat/trusted-publishing

Conversation

@hoegertn

@hoegertn hoegertn commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Issue # (if applicable)

N/A — fixes the failing publish jobs on the release workflow (npm 404 on PUT, PyPI 403 Forbidden) caused by expired registry secrets.

Reason for this change

The release workflow authenticates to npm with a long-lived NPM_TOKEN and to PyPI with TWINE_USERNAME/TWINE_PASSWORD. Those credentials expired, so the 0.2.0 release failed both publish jobs (npm error 404 ... PUT .../@open-constructs%2faws-cdk, and 403 Forbidden from https://upload.pypi.org/legacy/). Long-lived tokens have to be rotated manually and silently break about a year out.

Description of changes

Switch both publish jobs to OIDC trusted publishing, configured the projen way in .projenrc.ts (the workflow is generated, not hand-edited):

  • npmTrustedPublishing: true — the npm job drops NPM_TOKEN, sets NPM_TRUSTED_PUBLISHER: "true", and keeps provenance under the existing id-token: write permission.
  • publishToPypi.trustedPublishing: true — the PyPI job drops TWINE_USERNAME/TWINE_PASSWORD, gains id-token: write, and sets PYPI_TRUSTED_PUBLISHER: "true".

publib exchanges the short-lived GitHub OIDC token for each registry at publish time. No stored registry secrets remain.

One-time setup required before the next release (cannot be done in code):

  • npmjs.com: register a trusted publisher for @open-constructs/aws-cdk pointing at this repo's release workflow.
  • pypi.org: add a GitHub trusted publisher for open-constructs-aws-cdk (repo open-constructs/aws-cdk-library, workflow release.yml).

Description of how you validated changes

Ran npx projen and inspected the regenerated .github/workflows/release.yml: the npm job now carries NPM_TRUSTED_PUBLISHER with no NPM_TOKEN, and the PyPI job carries PYPI_TRUSTED_PUBLISHER with id-token: write and no twine secrets.

Checklist


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

…tokens

Switch the release workflow off long-lived registry credentials and onto
OIDC trusted publishing for both registries, configured the projen way:

- npmTrustedPublishing: true -> npm job drops NPM_TOKEN, sets
  NPM_TRUSTED_PUBLISHER and keeps provenance via id-token: write.
- publishToPypi.trustedPublishing: true -> PyPI job drops TWINE_USERNAME
  and TWINE_PASSWORD, gains id-token: write and PYPI_TRUSTED_PUBLISHER.

Both jobs now authenticate with short-lived GitHub OIDC tokens exchanged by
publib, removing the expiring NPM_TOKEN / TWINE_PASSWORD secrets that caused
the 0.2.0 release to fail npm (404 on PUT) and PyPI (403 Forbidden).

The trusted publishers must be registered once on npmjs.com and pypi.org
before the next release.
@hoegertn
hoegertn added this pull request to the merge queue Oct 10, 2026
Merged via the queue into main with commit 5c1e214 Oct 10, 2026
7 of 8 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.

2 participants