Skip to content

fix(ci): switch publish-package.yml to npm Trusted Publishers (OIDC) - #395

Merged
abbaseya merged 1 commit into
mainfrom
fix/publish-package-trusted-publisher
May 25, 2026
Merged

fix(ci): switch publish-package.yml to npm Trusted Publishers (OIDC)#395
abbaseya merged 1 commit into
mainfrom
fix/publish-package-trusted-publisher

Conversation

@abbaseya

@abbaseya abbaseya commented May 25, 2026

Copy link
Copy Markdown
Collaborator

Summary

The previous flow authenticated npm publish with a long-lived NPM_TOKEN whose per-package allowlist couldn't be inspected or rotated by the org owners. Out of 13 @convertcom/js-sdk-* packages, only js-sdk and js-sdk-cloudflare could be published with that token (last success: 2026-04-06). Seven GitHub-tagged versions never made it to npm:

Package npm latest Missing on npm
@convertcom/js-sdk 4.4.0 4.4.1, 4.4.2
@convertcom/js-sdk-types 3.11.0 3.12.0, 3.13.0
@convertcom/js-sdk-utils 2.2.3 2.3.0, 2.4.0
@convertcom/js-sdk-rules 2.1.4 2.2.0

All packages have now been configured with npm Trusted Publishers on the npm side, listing this workflow file (publish-package.yml) as a trusted publisher. This PR updates the workflow accordingly.

Workflow changes

  1. permissions: id-token: write at the job level — required by npm OIDC.
  2. npm install -g npm@latest after setup-node — Trusted Publishers OIDC needs npm CLI ≥ 11.5.1; Node 22 ships 10.9.x.
  3. actions/checkout@v4 with ref: ${{ github.event.release.tag_name || inputs.tag }} — fixes a pre-existing bug where workflow_dispatch always built main HEAD instead of the dispatched tag, making it impossible to publish older versions. This is what unblocks the 7-version backfill.
  4. Removed NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} env from all 13 publish steps — OIDC replaces it; leaving the token in would defeat the security gain.

Test plan

  • After merge, dispatch each of the 7 missing-version tags via the workflow and confirm they appear on npm:
    • gh workflow run publish-package.yml -f tag=js-sdk-types-v3.12.0
    • gh workflow run publish-package.yml -f tag=js-sdk-types-v3.13.0
    • gh workflow run publish-package.yml -f tag=js-sdk-utils-v2.3.0
    • gh workflow run publish-package.yml -f tag=js-sdk-utils-v2.4.0
    • gh workflow run publish-package.yml -f tag=js-sdk-rules-v2.2.0
    • gh workflow run publish-package.yml -f tag=js-sdk-v4.4.1
    • gh workflow run publish-package.yml -f tag=js-sdk-v4.4.2
  • Verify npm view @convertcom/js-sdk-types versions reports 3.12.0 and 3.13.0 after the corresponding runs.

🤖 Generated with Claude Code

The previous flow authenticated `npm publish` with a long-lived
`NPM_TOKEN` secret whose per-package allowlist couldn't be
inspected or rotated by the convertcom org owners. Result: out of
13 `@convertcom/js-sdk-*` packages, only `js-sdk` and
`js-sdk-cloudflare` could be published (last success: 2026-04-06);
publishes for `types`, `utils`, `rules`, etc. have been 404'ing on
the registry PUT for months — 7 GitHub-tagged versions never made
it to npm.

With Trusted Publishers (per npm docs at
https://docs.npmjs.com/trusted-publishers), authentication moves to
GitHub OIDC, configured per package by the npm org owners. Each
package's npm settings now lists this workflow file as a trusted
publisher, so the workflow needs three changes:

1. Grant the job `id-token: write` so the runner can mint an OIDC
   token for npm to validate.
2. Upgrade the bundled npm CLI to >= 11.5.1 (Node 22 ships 10.9.x);
   OIDC publish support requires the newer CLI.
3. Drop the `NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}` env from
   each publish step — OIDC replaces it; leaving the token in
   would defeat the security gain.

Also pins `actions/checkout@v4` to the tag passed via
`workflow_dispatch -f tag=<tag>` (or the release event's
`tag_name`), so backfill dispatches build the *tagged commit's*
source — not main HEAD — which is required to publish the 7
missing prior versions (e.g. dispatching `js-sdk-types-v3.12.0`
must build the 3.12.0 source, not the current 3.13.0 in
`packages/types/package.json` on main).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Note

Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported.

@abbaseya
abbaseya requested a review from a team May 25, 2026 16:28
@abbaseya abbaseya self-assigned this May 25, 2026
@sonarqubecloud

Copy link
Copy Markdown

@abbaseya
abbaseya merged commit 2a41c3e into main May 25, 2026
6 checks passed
@abbaseya
abbaseya deleted the fix/publish-package-trusted-publisher branch May 25, 2026 16:30
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