Skip to content

[GHA] Fix OIDC publish, unify top-level package-publishing workflows#57255

Closed
robhogan wants to merge 1 commit into
mainfrom
robhogan/unified-publish-workflow
Closed

[GHA] Fix OIDC publish, unify top-level package-publishing workflows#57255
robhogan wants to merge 1 commit into
mainfrom
robhogan/unified-publish-workflow

Conversation

@robhogan

Copy link
Copy Markdown
Contributor

Problem

npm Trusted Publishing matches the workflow_ref OIDC claim, which is always the top-level workflow filename. npm allows only ONE trusted publisher per package. The prior migration (#57099) used workflow_call to route all publishes through publish-npm.yml, but workflow_ref resolves to the caller (e.g. nightly.yml), not the reusable child, so the Trusted Publisher entry for publish-npm.yml never matches.

Solution

Merge all three publish entry points into publish-npm.yml itself, triggered by all three event types:

  • push.tags: v0.* -> release mode (was publish-release.yml)
  • schedule + workflow_dispatch -> nightly mode (was nightly.yml)
  • push.branches: main, *-stable -> bumped-packages mode (was publish-bumped-packages.yml)

A determine_mode job inspects the trigger and sets the mode. Downstream jobs use conditional if: expressions to run only the relevant build/publish steps.

Since publish-npm.yml is now always the top-level workflow, workflow_ref always resolves to publish-npm.yml, which matches what's already configured on npm.

…npm.yml

## Problem

npm Trusted Publishing matches the `workflow_ref` OIDC claim, which
is always the top-level workflow filename. npm allows only ONE trusted
publisher per package. The prior migration (#57099) used
`workflow_call` to route all publishes through `publish-npm.yml`,
but `workflow_ref` resolves to the *caller* (e.g. `nightly.yml`),
not the reusable child — so the Trusted Publisher entry for
`publish-npm.yml` never matches.

## Solution

Merge all three publish entry points into `publish-npm.yml` itself,
triggered by all three event types:

  - `push.tags: v0.*` → release mode (was publish-release.yml)
  - `schedule + workflow_dispatch` → nightly mode (was nightly.yml)
  - `push.branches: main, *-stable` → bumped-packages mode
    (was publish-bumped-packages.yml)

A `determine_mode` job inspects the trigger and sets the mode.
Downstream jobs use conditional `if:` expressions to run only
the relevant build/publish steps.

Since `publish-npm.yml` is now always the top-level workflow,
`workflow_ref` always resolves to `publish-npm.yml` ✅.

## Key design points

- **No JS changes** — the publish scripts are unchanged. The build
  and publish still happen in the same job, on the same runner, with
  the same container. No artifact handoff or pack-only mode needed.

- **Reusable workflow_call children are fine** — prebuild-ios-*.yml,
  generate-changelog.yml, etc. remain as `workflow_call` children.
  Only the file that calls `npm publish` must be the top-level
  workflow; child workflows don't affect the OIDC claim.

- **Old workflow files kept as stubs** — publish-release.yml,
  nightly.yml, and publish-bumped-packages.yml are replaced with
  minimal deprecation notices so that external links/dashboards
  don't 404.

- **`always()` + explicit result checks** — publish_react_native
  depends on build_android (nightly-only) and prebuild_* jobs.
  In release mode, build_android is skipped. The `always()`
  prevents cascading skips, while explicit result checks ensure
  we don't publish after a failed build.

## npm Trusted Publisher config (manual step)

For each of the 24 packages, configure on npmjs.com:
  Organization: react
  Repository:   react-native
  Workflow:     publish-npm.yml
  Environment:  npm-publish
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jun 17, 2026
@meta-codesync

meta-codesync Bot commented Jun 17, 2026

Copy link
Copy Markdown

@robhogan has imported this pull request. If you are a Meta employee, you can view this in D108894981.

@github-actions

Copy link
Copy Markdown

Warning

Missing Test Plan

Please add a "## Test Plan" section to your PR description. A Test Plan lets us know how these changes were tested.

Caution

Missing Changelog

Please add a Changelog to your PR description. See Changelog format

@cortinico cortinico left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

@meta-codesync meta-codesync Bot closed this in 567b9f0 Jun 17, 2026
@meta-codesync meta-codesync Bot added the Merged This PR has been merged. label Jun 17, 2026
@meta-codesync

meta-codesync Bot commented Jun 17, 2026

Copy link
Copy Markdown

@robhogan merged this pull request in 567b9f0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants