Skip to content

Update workflows for Npm trusted publishing - #81

Merged
acutmore merged 3 commits into
mainfrom
npm-trusted-publishing
Nov 23, 2026
Merged

acutmore merged 3 commits into
mainfrom
npm-trusted-publishing

Conversation

@acutmore

Copy link
Copy Markdown
Collaborator

Updates the workflow as per https://docs.npmjs.com/trusted-publishers

@acutmore
acutmore requested a review from tchetwin November 18, 2026 16:34
@acutmore
acutmore force-pushed the npm-trusted-publishing branch from 96a1bd4 to 458f95d Compare November 18, 2026 17:10
Grant `id-token: write` so npm can authenticate with GitHub's OIDC
token, and drop the NPM_TOKEN secret. Use Node 24, because trusted
publishing needs npm >= 11.5.1 and Node 20 and 22 bundle npm 10.
Trusted publishing also generates provenance automatically. The
permissions, action versions and disabled cache follow npm's example
workflow.

Run gen-types and build as explicit steps, so that a publish with
lifecycle scripts disabled (ignore-scripts) can't skip `prepack` and
publish a package without `out/`.

Signed-off-by: aclaymore <aclaymore@bloomberg.net>
Match publish.yml, so that CI exercises the same action versions that
the publish workflow uses.

Signed-off-by: aclaymore <aclaymore@bloomberg.net>
@acutmore
acutmore force-pushed the npm-trusted-publishing branch from 458f95d to 9b1c963 Compare November 18, 2026 17:11
Comment thread .github/workflows/publish.yml Outdated
Comment on lines +24 to +26
# Build explicitly so publishing doesn't depend on lifecycle scripts (e.g. ignore-scripts)
- run: npm run gen-types
- run: npm run build

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"My" "research" suggests that in npm 12 npm publish will continue to run (unless ignore-scripts=true is explicitly set somewhere).

By contrast, npm ci will require allow-listed pre/postinstalls.

Consequently I think these lines are just achieving duplication of the run scripts with no added security benefit

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's not a security thing, it's just belt and braces that we build.
The build is so cheap, doing it twice seems better than zero.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to be explicit we may as well do NPM_CONFIG_IGNORE_SCRIPTS: "true" and get both the ~security-benefit and avoid any potential non-idempotence of the scripts

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good shout. Done in 8279674

Signed-off-by: aclaymore <aclaymore@bloomberg.net>
@acutmore
acutmore force-pushed the npm-trusted-publishing branch from a624010 to 8279674 Compare November 23, 2026 10:16
@acutmore
acutmore requested a review from tchetwin November 23, 2026 10:17
@acutmore
acutmore merged commit d8c8551 into main Nov 23, 2026
4 checks passed
@acutmore
acutmore deleted the npm-trusted-publishing branch November 23, 2026 18:44
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