Skip to content

ci(release): Publish npm packages with OIDC trusted publishing - #5275

Draft
thomas-lebeau wants to merge 3 commits into
mainfrom
thomas.lebeau/RUM-19961-npm-oidc
Draft

thomas-lebeau wants to merge 3 commits into
mainfrom
thomas.lebeau/RUM-19961-npm-oidc

Conversation

@thomas-lebeau

@thomas-lebeau thomas-lebeau commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

RUM-19961. step-6_publish-npm publishes from GitLab with a long-lived npm token that bypasses 2FA (ci.browser-sdk.npm_token). These tokens will be unable to publish starting January 2027 (deprecation). NPM Releases Best Practices recommends OIDC trusted publishing, which only works from GitHub Actions.

Changes

GitLab keeps control of when we publish (after the CDN regions, behind the cordon check, before the developer extension), but the publish itself runs in GitHub Actions:

  • .github/workflows/publish-npm.yml (new): runs on workflow_dispatch in the npm-publish environment, with id-token: write. It checks that the ref is the v<package.json version> tag, runs yarn install --immutable, then runs publish-npm.ts with provenance turned on (YARN_NPM_CONFIG_PROVENANCE). The job has no dependency cache, no persisted git credentials and a 30-minute timeout.
  • publish-npm.ts: no longer reads the npm token. Yarn 4.18.1 swaps the GitHub OIDC token for a short-lived npm token on its own. Setting YARN_NPM_AUTH_TOKEN by hand still works, for a new package's first publish. The failure hint now points to the trusted publisher settings.
  • publish-npm-on-github.ts (new), run by step-6_publish-npm in deploy-auto and deploy-manual: it starts the workflow on vX.Y.Z with return_run_details: true, which returns the run id and URL directly, prints the run URL, then checks the run until it completes. It fails if the conclusion isn't success or after 40 minutes (the job timeout plus time in the queue, less than the one-hour token lifetime). The error says that a retry is safe.
  • .github/chainguard/self.gitlab.publish.sts.yaml (new): a tag-only dd-octo-sts policy with actions: write.
  • getNpmToken is removed (no longer used). renew-token.ts and the SSM secret stay until after the first OIDC release.

Before merging, outside this repo:

  • Create the npm-publish GitHub environment, limited to v* tags
  • Register the 14 packages as trusted publishers on npm (DataDog/browser-sdk, publish-npm.yml, env npm-publish) via #guild-dd-node-js

After the first successful release: enforce "Require 2FA and disallow tokens", then delete ci.browser-sdk.npm_token, renew-token.ts and the release workflow page's token instructions.

Not verified yet (checked by the test-tag run below):

  • that a run started through the token service passes the environment's tag rule
  • that the dispatch response (return_run_details) works with our API version header

Test instructions

  • yarn test:script covers publish-npm.spec.ts and the new publish-npm-on-github.spec.ts: it dispatches on the release tag, waits for the run to complete, and fails on failure, cancellation or timeout.
  • End to end, once the environment and npm config exist: push a test tag whose name matches the package.json version and run step-6_publish-npm from deploy-manual. Check the run URL in the job log, and that the run either publishes with provenance or is a no-op with --tolerate-republish.

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

Refs: RUM-19961

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Bundles Sizes Evolution

📦 Bundle Name Base Size Local Size 𝚫 𝚫% Status
Rum Salesforce 194.46 KiB 194.46 KiB 0 B 0.00% ✅
Rum 194.44 KiB 194.44 KiB 0 B 0.00% ✅
Rum Salesforce Profiler 8.10 KiB 8.10 KiB 0 B 0.00% ✅
Rum Profiler 8.10 KiB 8.10 KiB 0 B 0.00% ✅
Rum Salesforce Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Rum Recorder 32.80 KiB 32.80 KiB 0 B 0.00% ✅
Logs 60.21 KiB 60.21 KiB 0 B 0.00% ✅
Rum Slim 149.83 KiB 149.83 KiB 0 B 0.00% ✅
Worker 24.23 KiB 24.23 KiB 0 B 0.00% ✅
Rum Shopify 225.98 KiB 225.98 KiB 0 B 0.00% ✅
Rum Shopify Profiler 8.10 KiB 8.10 KiB 0 B 0.00% ✅
Rum Shopify Recorder 4.85 KiB 4.85 KiB 0 B 0.00% ✅
Early Collection 309 B 309 B 0 B 0.00% ✅

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 78.07% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 326cb20 | Docs | View more details | Give us feedback!

@thomas-lebeau
thomas-lebeau force-pushed the thomas.lebeau/RUM-19961-npm-oidc branch from 82732dc to aff6653 Compare November 20, 2026 19:02
@thomas-lebeau thomas-lebeau changed the title 👷 [RUM-19961] Publish npm packages with OIDC trusted publishing from GitHub Actions ci(release): Publish npm packages with OIDC trusted publishing Nov 24, 2026
- Disable the dependency cache and persisted git credentials in the
  publishing job.
- Give the job a 30 minute timeout, and wait up to 40 minutes for it
  from GitLab (queueing included, under the GitHub token lifetime).
- Say in the GitLab error that retrying the job is safe.

This branch has not been deployed

No deployments
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.

1 participant