Skip to content

chore: use NPM trusted publishing - #3071

Merged
Saad Najmi (Saadnajmi) merged 5 commits into
mainfrom
copilot/switch-to-github-actions
Aug 4, 2026
Merged

chore: use NPM trusted publishing#3071
Saad Najmi (Saadnajmi) merged 5 commits into
mainfrom
copilot/switch-to-github-actions

Conversation

Copilot AI commented Jul 31, 2026

Copy link
Copy Markdown

Replaces the ADO-based npm publish pipeline with a GitHub Actions workflow that uses npm Trusted Publishing (OIDC) for the main publish step — no stored npm token required for npm publish.

Changes

  • .github/workflows/microsoft-npm-publish.yml — New workflow triggered on *-stable branch pushes. Runs in an npm-publish GitHub environment (add protection rules there). Uses id-token: write + --provenance so yarn exchanges a GitHub OIDC token directly with npmjs.com rather than a stored secret. The npm dist-tag add step (applying additional dist-tags) still requires a NPM_TOKEN secret since OIDC doesn't cover that operation.

  • .ado/scripts/configure-publish.mts — Added enablePublishingOnGitHubActions() that writes publish_react_native_macos=1 to GITHUB_OUTPUT, so the new workflow can gate its publish steps on this output. Previously only the ADO ##vso[task.setvariable...] signal was emitted.

  • .ado/scripts/apply-additional-tags.mjs — Token can now come from NODE_AUTH_TOKEN env var as a fallback to --token. When using the env-var path (GHA), the token is not passed as a CLI argument — actions/setup-node has already wired NODE_AUTH_TOKEN into .npmrc, so npm dist-tag add picks it up from there. The --token CLI arg path (ADO) is unchanged.

Manual steps required before this workflow runs

  1. npmjs.com: add a Trusted Publisher for react-native-macos and @react-native-macos/virtualized-lists — repo microsoft/react-native-macos, workflow microsoft-npm-publish.yml, environment npm-publish
  2. GitHub repo Settings → Environments: create the npm-publish environment with desired approval rules
  3. GitHub secret: add NPM_TOKEN to that environment (granular automation token scoped to the two packages, used only for dist-tag operations)
  4. ADO: once verified, disable .ado/publish.yml

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@Saadnajmi Saad Najmi (Saadnajmi) changed the title Switch npm publishing from Azure Pipelines to GitHub Actions with npm Trusted Publishing chore: use npm Trusted Publishing Jul 31, 2026
@Saadnajmi
Saad Najmi (Saadnajmi) marked this pull request as ready for review July 31, 2026 16:19
@Saadnajmi
Saad Najmi (Saadnajmi) requested a review from a team as a code owner July 31, 2026 16:19
Comment thread .github/workflows/microsoft-npm-publish.yml Outdated
Comment thread .ado/scripts/apply-additional-tags.mjs Outdated
Comment thread .ado/scripts/apply-additional-tags.mjs Outdated
Comment thread .ado/scripts/configure-publish.mts Outdated
Comment thread .ado/scripts/configure-publish.mts Outdated
Comment thread .github/workflows/microsoft-npm-publish.yml Outdated
Comment thread .github/workflows/microsoft-npm-publish.yml Outdated
Comment thread .github/workflows/microsoft-npm-publish.yml Outdated
Comment thread .github/workflows/microsoft-npm-publish.yml Outdated
Comment thread .github/workflows/microsoft-npm-publish.yml Outdated
Comment thread .ado/scripts/apply-additional-tags.mjs Outdated
Comment thread .ado/scripts/configure-publish.mts Outdated
Comment thread .github/workflows/microsoft-npm-publish.yml Outdated
Comment thread .github/workflows/microsoft-npm-publish.yml
@Saadnajmi Saad Najmi (Saadnajmi) changed the title chore: use npm Trusted Publishing chore: use NPM trusted publishing Jul 31, 2026
Copilot AI added 5 commits August 3, 2026 19:40
- Add enablePublishingOnGitHubActions() to configure-publish.mts so the
  new GHA workflow can gate publish steps via GITHUB_OUTPUT
- Update apply-additional-tags.mjs to fall back to NODE_AUTH_TOKEN env
  var when --token is not provided; avoids token-in-process-args on GHA
- Add .github/workflows/microsoft-npm-publish.yml: OIDC trusted publishing
  on *-stable branch pushes, with npm-publish environment protection
- Remove verbose/obvious comments from workflow and scripts
- Drop --token CLI arg from apply-additional-tags.mjs; use NODE_AUTH_TOKEN
  env var only; update ADO job accordingly
- Remove JSDoc from self-explanatory enablePublishingOnGitHubActions()
- Add isGitHubActions boolean to configure-publish.mts and use it to
  select between ADO and GHA signaling (instead of calling both)
@Saadnajmi
Saad Najmi (Saadnajmi) force-pushed the copilot/switch-to-github-actions branch from 76a13b6 to 11a03a1 Compare August 4, 2026 02:40
Comment thread .github/workflows/microsoft-npm-publish.yml
@Saadnajmi
Saad Najmi (Saadnajmi) merged commit b3a73ab into main Aug 4, 2026
28 checks passed
@Saadnajmi
Saad Najmi (Saadnajmi) deleted the copilot/switch-to-github-actions branch August 4, 2026 18:33
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.

3 participants