Skip to content

chore(NODE-7562): use npm trusted publisher for nightly release#4930

Open
tadjik1 wants to merge 3 commits intomainfrom
NODE-7235-nightly-trusted-publisher
Open

chore(NODE-7562): use npm trusted publisher for nightly release#4930
tadjik1 wants to merge 3 commits intomainfrom
NODE-7235-nightly-trusted-publisher

Conversation

@tadjik1
Copy link
Copy Markdown
Member

@tadjik1 tadjik1 commented Apr 29, 2026

Description

Merge this PR only after configuration on NPM for trusted publisher is complete! Workflow name for NPM - npm-publish.yml.

Summary of Changes

Migrates the nightly release flow off NPM_TOKEN and onto npm Trusted Publishing (OIDC). The pattern routes publishing through a dedicated, single-purpose workflow that we can register once on npmjs.com as the trusted publisher for the mongodb package.

npm Trusted Publishing currently allows one trusted publisher entry per package, and the OIDC validation matches against the top-level caller workflow's filename - so workflow_call does not work around this. Dispatching the publish workflow via the workflow_dispatch API lets us register a single publisher entry and eventually route every release flow (nightly, latest, alpha, backports) through it.

Test on nightly build first, before promoting to the rest.

Double check the following

  • Lint is passing (npm run check:lint)
  • Self-review completed using the steps outlined here
  • PR title follows the correct format: type(NODE-xxxx)[!]: description
    • Example: feat(NODE-1234)!: rewriting everything in coffeescript
  • Changes are covered by tests
  • New TODOs have a related JIRA ticket

@tadjik1 tadjik1 force-pushed the NODE-7235-nightly-trusted-publisher branch from c824195 to 4a1c49e Compare April 30, 2026 08:46
@tadjik1 tadjik1 changed the title chore(NODE-7235): use npm trusted publisher for nightly release chore(NODE-7562): use npm trusted publisher for nightly release Apr 30, 2026
@tadjik1 tadjik1 force-pushed the NODE-7235-nightly-trusted-publisher branch from 5898d69 to 96e2daf Compare April 30, 2026 17:11
@tadjik1 tadjik1 force-pushed the NODE-7235-nightly-trusted-publisher branch from 96e2daf to 8170588 Compare April 30, 2026 17:16
@tadjik1 tadjik1 marked this pull request as ready for review April 30, 2026 17:19
@tadjik1 tadjik1 requested a review from a team as a code owner April 30, 2026 17:19
Copilot AI review requested due to automatic review settings April 30, 2026 17:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Migrates the nightly npm publish flow from using an NPM_TOKEN secret to using npm Trusted Publishing (OIDC) by routing publishing through a dedicated, dispatch-triggered workflow that can be registered once as the trusted publisher for the mongodb package.

Changes:

  • Document the nightly release exception and Trusted Publishing setup in release notes.
  • Update release-nightly.yml to dispatch a dedicated npm-publish.yml workflow instead of running npm publish directly.
  • Add npm-publish.yml (OIDC-enabled) and a helper script to dispatch and wait for workflow completion.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
etc/notes/releasing.md Documents nightly publishing via the new trusted-publisher workflow.
.github/workflows/release-nightly.yml Replaces direct npm publish with a dispatch to the dedicated publish workflow and adjusts permissions.
.github/workflows/npm-publish.yml New dispatch-triggered workflow that performs checkout + publish using OIDC (id-token: write).
.github/scripts/dispatch-and-wait.mjs New helper to dispatch a workflow via gh and block until the run finishes.

Comment on lines +58 to +62
// gh prints e.g. "https://github.com/owner/repo/actions/runs/<id>"
const match = dispatch.stdout.match(/\/actions\/runs\/(\d+)/);
if (!match) {
console.error('Could not extract run id from gh workflow run output:', dispatch.stdout);
process.exit(1);
Comment on lines +12 to +24
inputs:
tag:
description: 'npm dist-tag (e.g. nightly, latest, alpha)'
required: true
type: string
version:
description: 'Package version to publish'
required: true
type: string
ref:
description: 'Git ref (commit SHA preferred) to publish from'
required: true
type: string
Comment on lines 30 to +36
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GH_TOKEN: ${{ github.token }}
run: |
node ./.github/scripts/dispatch-and-wait.mjs npm-publish.yml \
tag=nightly \
version="$(node -p "require('./package.json').version")" \
ref="${{ github.sha }}"
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