Skip to content

chore(release): stage the wrapper packages in the Rust release workflow - #12804

Merged
zkochan merged 1 commit into
mainfrom
pacquet-release-stage-wrappers
Jul 4, 2026
Merged

zkochan merged 1 commit into
mainfrom
pacquet-release-stage-wrappers

Conversation

@zkochan

@zkochan zkochan commented Jul 4, 2026 •

Copy link
Copy Markdown
Member

Summary

The "Release pnpm (Rust)" workflow failed on its first publish attempt (run 28718351330): it authenticated everything via npm trusted publishing, but npm allows only one trusted publisher per package, and pnpm / @pnpm/exe already have theirs bound to release.yml (the v11 TS releases). The OIDC token exchange returned 404, pnpm skipped OIDC, and the unauthenticated PUT failed.

This splits the publish step in two:

  1. Natives via trusted publishing. The @pnpm/exe.<target> packages are published only by this workflow, so their trusted publishers can be pointed at pacquet-release-to-npm.yml (environment release) without conflict. They go live directly.
  2. Wrappers via staged publishing. pnpm and @pnpm/exe are uploaded with pnpm stage publish using the static NPM_TOKEN. Nothing goes live from CI for those two names — a maintainer promotes them with pnpm stage approve <stage-id> --otp, which is where the proof-of-presence is consumed. The stage ids are teed into the job summary for the approver.

--provenance keeps working in both steps since it only needs the id-token: write OIDC token, not trusted publishing. The steps must stay separate because pnpm publish skips OIDC as soon as a static _authToken is configured (#11495). set -o pipefail guards the tee pipe because the runner's default bash is -e without pipefail.

Depends on #12805: the root .pnpmfile.cjs beforePacking hook currently rejects the v12 wrapper manifests (they intentionally declare optionalDependencies on the natives); that PR version-gates the hook so they pass through untouched.

Registry-side prerequisites (manual, not part of this PR): configure trusted publishers for the eight @pnpm/exe.<target> packages against this workflow file, and ensure NPM_TOKEN has staged-publish rights on pnpm and @pnpm/exe.

Squash Commit Body

The Rust release workflow authenticated every publish via npm trusted
publishing, but npm allows a single trusted publisher per package and
pnpm / @pnpm/exe have theirs bound to release.yml (the v11 TS
releases). The OIDC token exchange therefore returned 404, pnpm skipped
OIDC, and the unauthenticated PUT failed with E404.

Split the publish into two steps:

1. The @pnpm/exe.<target> natives are published only from this
   workflow, so they keep trusted publishing and go live directly.
2. The pnpm and @pnpm/exe wrappers are staged with `pnpm stage publish`
   using the static NPM_TOKEN. Nothing goes live from CI for those two
   names; a maintainer promotes them with
   `pnpm stage approve <stage-id> --otp`, which is where the
   proof-of-presence is consumed. Stage ids are teed into the job
   summary for the approver.

The steps must stay separate because pnpm publish skips OIDC as soon
as a static _authToken is configured (pnpm/pnpm#11495). --provenance
keeps working in both steps: it needs only the id-token: write OIDC
token, not trusted publishing. set -o pipefail guards the tee pipe
because the runner's default bash is -e without pipefail.

Depends on the pnpmfile version-gate from pnpm/pnpm#12805.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pacquet/ port, or the description notes what still needs porting.
    (CI-workflow-only change; no CLI code touched, nothing to port.)
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. (Not needed — no published package is changed.)

Written by an agent (Claude Code, claude-fable-5).

The Rust release workflow authenticated every publish via npm trusted
publishing, but npm allows a single trusted publisher per package and
`pnpm` / `@pnpm/exe` have theirs bound to release.yml (the v11 TS
releases). The OIDC token exchange therefore returned 404, pnpm skipped
OIDC, and the unauthenticated PUT failed with E404.

Split the publish into two steps:

1. The `@pnpm/exe.<target>` natives are published only from this
   workflow, so they keep trusted publishing and go live directly.
2. The `pnpm` and `@pnpm/exe` wrappers are staged with
   `pnpm stage publish` using the static NPM_TOKEN. Nothing goes live
   from CI for those two names; a maintainer promotes them with
   `pnpm stage approve <stage-id> --otp`, which is where the
   proof-of-presence is consumed. Stage ids are teed into the job
   summary for the approver.

The steps must stay separate because `pnpm publish` skips OIDC as soon
as a static _authToken is configured (#11495). `--provenance`
keeps working in both steps: it needs only the `id-token: write` OIDC
token, not trusted publishing. `set -o pipefail` guards the tee pipe
because the runner's default bash is -e without pipefail.
Copilot AI review requested due to automatic review settings July 4, 2026 20:47

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The pacquet npm release workflow is updated to publish native packages and pnpm/@pnpm/exe wrapper packages via two separate steps instead of one combined step. Native packages use trusted OIDC publishing with provenance, while wrappers are staged using a temporary static NPM_TOKEN-based auth token that is removed on exit.

Changes

Publish Workflow Split

Layer / File(s) Summary
Header documentation update
.github/workflows/pacquet-release-to-npm.yml
Comments clarify the native-vs-wrapper publish split, the required pnpm stage approve step, and the default next-12 dist-tag.
Separated publish steps
.github/workflows/pacquet-release-to-npm.yml
Replaces the single combined publish step with a trusted-publishing step for pacquet-* native packages and a static-token staging step for pnpm/@pnpm/exe wrappers, including stage output logging and temporary token cleanup via a shell trap.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PublishJob
  participant NpmRegistry
  participant GITHUB_STEP_SUMMARY

  PublishJob->>NpmRegistry: Publish pacquet/npm/pacquet-* via trusted publishing (OIDC, provenance)
  PublishJob->>PublishJob: Set npm auth token from NPM_TOKEN
  PublishJob->>NpmRegistry: pnpm stage publish for pacquet/npm/pnpm*
  NpmRegistry-->>PublishJob: Stage output (stage ids)
  PublishJob->>GITHUB_STEP_SUMMARY: Append stage output
  PublishJob->>PublishJob: Delete npm auth token (trap on exit)
Loading

Possibly related PRs

  • pnpm/pnpm#11496: Splits publishing steps to control token usage vs trusted OIDC/provenance publishing for pnpm/@pnpm/exe.
  • pnpm/pnpm#11652: Modifies the same workflow's publish job for native vs wrapper publishing behavior.
  • pnpm/pnpm#12641: Changes the npm publish step configuration in the same workflow file.

Suggested labels: product: pacquet

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pacquet-release-stage-wrappers

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix Rust release workflow by staging wrapper packages and OIDC-publishing natives

🐞 Bug fix ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Split Rust npm publish into trusted-native and staged-wrapper steps to satisfy npm publisher
 limits.
• Publish @pnpm/exe. via OIDC; stage pnpm/@pnpm/exe with NPM_TOKEN for manual approval.
• Surface stage IDs in job summary and harden token handling with pipefail + cleanup trap.
Diagram

graph TD
  A["GitHub Actions: pacquet-release-to-npm.yml"] --> B["Build pacquet npm packages"] --> C["Publish natives: @pnpm/exe.<target> (OIDC)"] --> D[("npm registry")]
  B --> E["Stage wrappers: pnpm, @pnpm/exe (NPM_TOKEN)"] --> F["Stage IDs in job summary"]
  E --> D
  G["Maintainer"] --> H["pnpm stage approve --otp"] --> D
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Split wrappers into a separate manual-approval workflow
  • ➕ Clear separation between automated publishing and human-gated promotion
  • ➕ Can restrict the approval workflow permissions/environment more tightly
  • ➖ More workflow plumbing (artifact passing, inputs, discoverability)
  • ➖ Still requires staged publishing/token handling; doesn’t remove npm constraints
2. Publish wrappers with npm CLI using token (keep pnpm for natives)
  • ➕ Avoids pnpm-specific behavior where static _authToken disables OIDC
  • ➕ Potentially simpler auth scoping per step
  • ➖ Adds toolchain divergence and maintenance cost
  • ➖ Still needs careful provenance + staging semantics alignment

Recommendation: Keep the PR’s approach: publish natives first via OIDC trusted publishing, then stage wrappers with NPM_TOKEN and require manual pnpm stage approve --otp. This directly addresses npm’s single-trusted-publisher limitation and the pnpm behavior around _authToken disabling OIDC, while preserving provenance and making approval operationally easy via job-summary stage IDs.

Files changed (1) +36 / -9

Other (1) +36 / -9
pacquet-release-to-npm.ymlSplit npm publish into OIDC native publish and staged wrapper publish +36/-9

Split npm publish into OIDC native publish and staged wrapper publish

• Reworks the Rust release workflow to publish only '@pnpm/exe.<target>' packages via trusted publishing (OIDC), and stage 'pnpm'/'@pnpm/exe' wrapper packages using 'pnpm stage publish' with 'NPM_TOKEN'. Adds job-summary capture of stage IDs and hardens the step with 'pipefail' plus an auth-token cleanup trap to prevent leaking token config into the OIDC publish step.

.github/workflows/pacquet-release-to-npm.yml

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jul 4, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (2) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Dispatch exposes NPM token 🐞 Bug ⛨ Security ⭐ New
Description
The new wrapper-staging step consumes secrets.NPM_TOKEN without any github.ref/branch guard, so
a manually-dispatched run from an unreviewed/non-protected ref can execute ref-controlled code with
access to the npm token and exfiltrate it. This risk is amplified because workflow_dispatch can be
run from refs other than main, as documented elsewhere in the repo’s workflows.
Code

.github/workflows/pacquet-release-to-npm.yml[R236-244]

+      - name: Stage pnpm and @pnpm/exe wrappers (static token)
+        env:
+          TAG: ${{ inputs.tag }}
+          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+        run: |
+          set -o pipefail
+          trap 'pnpm config delete "//registry.npmjs.org/:_authToken" || true' EXIT
+          pnpm config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}"
+          for package in pacquet/npm/pnpm*; do
Evidence
The workflow is workflow_dispatch-only and now exports secrets.NPM_TOKEN into the environment
for the staging publish step, but there is no if: condition restricting execution to
main/protected refs. Another workflow in this repository explicitly notes that workflow_dispatch
may be triggered from a different ref, demonstrating this is a real execution mode to defend against
when secrets are involved.

.github/workflows/pacquet-release-to-npm.yml[10-12]
.github/workflows/pacquet-release-to-npm.yml[153-160]
.github/workflows/pacquet-release-to-npm.yml[236-244]
.github/workflows/update-lockfile.yml[39-43]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The workflow now injects `secrets.NPM_TOKEN` into a `workflow_dispatch` run, but does not restrict the job/step to a protected ref (e.g. `main`). This allows a maintainer (or any actor permitted to dispatch) to accidentally run the workflow against an unreviewed ref whose workflow/scripts are attacker-controlled, enabling token exfiltration.

### Issue Context
`workflow_dispatch` supports running on arbitrary refs; another workflow in this repo explicitly accounts for dispatch-from-non-main refs. Because this PR newly introduces a high-value secret into the workflow, it should be explicitly constrained in-repo (not only via out-of-band environment settings).

### Fix Focus Areas
- .github/workflows/pacquet-release-to-npm.yml[153-160]
- .github/workflows/pacquet-release-to-npm.yml[236-244]

### Suggested fix
Add an explicit ref gate, e.g.:
- Job-level: `publish: if: github.ref == 'refs/heads/main'` (or your protected release branch), or
- Step-level: apply the `if:` only to the static-token staging step (so native trusted publishing can still run if desired).

Optionally, fail fast with a clear error message when run from the wrong ref to prevent accidental dispatches.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Stage IDs exposed in summary 🐞 Bug ⛨ Security
Description
The workflow appends pnpm stage publish output to $GITHUB_STEP_SUMMARY, and that output includes
a UUID stageId that is later used to view/download/approve/reject staged artifacts. If the
registry treats the stage ID as an unguessable capability for accessing unpublished tarballs, this
leaks pre-approval artifacts to any user with access to the Actions run output (public in public
repos).
Code

.github/workflows/pacquet-release-to-npm.yml[R245-247]

+            # tee the output (which includes the stage id) into the job summary
+            # so the approver doesn't have to dig through the raw log.
+            pnpm stage publish "$package/" --tag "$TAG" --access public --provenance --no-git-checks | tee -a "$GITHUB_STEP_SUMMARY"
Evidence
The workflow writes stage publish output (which includes the stage ID) into the job summary. pnpm’s
stage publish renderer prints the stageId, which is a UUID, and the stage subcommands build registry
URLs directly from the stageId (including tarball download) without OTP being inherently required
for those read operations; therefore exposing stageId broadly can disclose staged artifacts if the
registry relies on stageId secrecy/capability semantics.

.github/workflows/pacquet-release-to-npm.yml[236-248]
pnpm11/releasing/commands/src/stage/rendering.ts[35-49]
pnpm11/releasing/commands/src/stage/parsing.ts[21-30]
pnpm11/releasing/commands/src/stage/download.ts[14-22]
pnpm11/releasing/commands/src/stage/request.ts[56-75]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workflow currently tees `pnpm stage publish` output into `$GITHUB_STEP_SUMMARY`. pnpm’s stage publish output includes a UUID `stageId`, and pnpm implements follow-up operations (view/download/approve/reject) by referencing that ID in `/-/stage/<stageId>/...` URLs.
If npm’s staging endpoints treat the `stageId` as an unguessable capability for accessing unpublished tarballs (common for UUID-based artifact handles), writing it into the job summary/logs makes those staged artifacts discoverable to anyone who can read the Actions run output.
## Issue Context
- The workflow is `workflow_dispatch` and runs in a public repo; Actions run logs and job summaries are typically readable by anyone with repo read access.
- pnpm’s stage IDs are validated as UUIDs, suggesting they’re intended to be unguessable identifiers.
## Fix Focus Areas
- .github/workflows/pacquet-release-to-npm.yml[241-248]
### Suggested remediation options
Pick one:
1. **Do not print stage IDs**: run `pnpm stage publish --json`, store JSON to a file for internal use, and write only package names/versions to the step summary. Instruct the approver to retrieve IDs via `pnpm stage list <pkg>@<version>` using their authenticated environment.
2. **Limit disclosure**: remove the `tee -a "$GITHUB_STEP_SUMMARY"` and keep output only where necessary, or gate summary output behind a manual/maintainer-only channel (if available in your release process).
(If stage IDs are explicitly non-sensitive because the registry enforces authz for all stage endpoints, consider documenting that assumption inline in the workflow so future readers don’t treat the UUID as a bearer secret.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit f8cf86a

Results up to commit f8cf86a


🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)


Remediation recommended
1. Stage IDs exposed in summary 🐞 Bug ⛨ Security
Description
The workflow appends pnpm stage publish output to $GITHUB_STEP_SUMMARY, and that output includes
a UUID stageId that is later used to view/download/approve/reject staged artifacts. If the
registry treats the stage ID as an unguessable capability for accessing unpublished tarballs, this
leaks pre-approval artifacts to any user with access to the Actions run output (public in public
repos).
Code

.github/workflows/pacquet-release-to-npm.yml[R245-247]

+            # tee the output (which includes the stage id) into the job summary
+            # so the approver doesn't have to dig through the raw log.
+            pnpm stage publish "$package/" --tag "$TAG" --access public --provenance --no-git-checks | tee -a "$GITHUB_STEP_SUMMARY"
Evidence
The workflow writes stage publish output (which includes the stage ID) into the job summary. pnpm’s
stage publish renderer prints the stageId, which is a UUID, and the stage subcommands build registry
URLs directly from the stageId (including tarball download) without OTP being inherently required
for those read operations; therefore exposing stageId broadly can disclose staged artifacts if the
registry relies on stageId secrecy/capability semantics.

.github/workflows/pacquet-release-to-npm.yml[236-248]
pnpm11/releasing/commands/src/stage/rendering.ts[35-49]
pnpm11/releasing/commands/src/stage/parsing.ts[21-30]
pnpm11/releasing/commands/src/stage/download.ts[14-22]
pnpm11/releasing/commands/src/stage/request.ts[56-75]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The workflow currently tees `pnpm stage publish` output into `$GITHUB_STEP_SUMMARY`. pnpm’s stage publish output includes a UUID `stageId`, and pnpm implements follow-up operations (view/download/approve/reject) by referencing that ID in `/-/stage/<stageId>/...` URLs.

If npm’s staging endpoints treat the `stageId` as an unguessable capability for accessing unpublished tarballs (common for UUID-based artifact handles), writing it into the job summary/logs makes those staged artifacts discoverable to anyone who can read the Actions run output.

## Issue Context
- The workflow is `workflow_dispatch` and runs in a public repo; Actions run logs and job summaries are typically readable by anyone with repo read access.
- pnpm’s stage IDs are validated as UUIDs, suggesting they’re intended to be unguessable identifiers.

## Fix Focus Areas
- .github/workflows/pacquet-release-to-npm.yml[241-248]

### Suggested remediation options
Pick one:
1. **Do not print stage IDs**: run `pnpm stage publish --json`, store JSON to a file for internal use, and write only package names/versions to the step summary. Instruct the approver to retrieve IDs via `pnpm stage list <pkg>@<version>` using their authenticated environment.
2. **Limit disclosure**: remove the `tee -a "$GITHUB_STEP_SUMMARY"` and keep output only where necessary, or gate summary output behind a manual/maintainer-only channel (if available in your release process).

(If stage IDs are explicitly non-sensitive because the registry enforces authz for all stage endpoints, consider documenting that assumption inline in the workflow so future readers don’t treat the UUID as a bearer secret.)

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@coderabbitai coderabbitai Bot 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.

🧹 Nitpick comments (1)
.github/workflows/pacquet-release-to-npm.yml (1)

245-247: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Optional: tee only captures stdout — stage IDs on stderr won't reach the summary.

| tee -a "$GITHUB_STEP_SUMMARY" forwards stdout only. If pnpm stage publish writes the stage id (or human-readable status) to stderr, the job summary the approver relies on will be empty. If unsure of the output stream, redirect stderr as well.

♻️ Capture both streams into the summary
-      pnpm stage publish "$package/" --tag "$TAG" --access public --provenance --no-git-checks | tee -a "$GITHUB_STEP_SUMMARY"
+      pnpm stage publish "$package/" --tag "$TAG" --access public --provenance --no-git-checks 2>&1 | tee -a "$GITHUB_STEP_SUMMARY"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/pacquet-release-to-npm.yml around lines 245 - 247, The job
summary for the pnpm stage publish step may miss the stage ID because the
current tee pipeline only captures stdout. Update the publish command in the
workflow step that uses pnpm stage publish and tee so both stdout and stderr are
written into GITHUB_STEP_SUMMARY, ensuring any stage ID or status emitted on
stderr is preserved for the approver.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In @.github/workflows/pacquet-release-to-npm.yml:
- Around line 245-247: The job summary for the pnpm stage publish step may miss
the stage ID because the current tee pipeline only captures stdout. Update the
publish command in the workflow step that uses pnpm stage publish and tee so
both stdout and stderr are written into GITHUB_STEP_SUMMARY, ensuring any stage
ID or status emitted on stderr is preserved for the approver.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: b9f4c395-4500-4a3e-95c7-f85c9bfc8a63

📥 Commits

Reviewing files that changed from the base of the PR and between 276d634 and f8cf86a.

📒 Files selected for processing (1)
  • .github/workflows/pacquet-release-to-npm.yml

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 4, 2026
@zkochan
zkochan merged commit b7908f9 into main Jul 4, 2026
26 checks passed
@zkochan
zkochan deleted the pacquet-release-stage-wrappers branch July 4, 2026 20:51
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit f8cf86a

zkochan added a commit that referenced this pull request Jul 4, 2026
…file pack hook (#12805)

The beforePacking guard threw for any package named 'pnpm' that
declares peerDependencies or optionalDependencies. From v12 the 'pnpm'
name is the Rust wrapper, whose generated manifest intentionally
declares optionalDependencies on the @pnpm/exe.<target> natives, so
the guard broke the Rust release.

The throw is redundant validation: the meta-updater config already
deletes those fields from the CLI manifest, so meta-updater --test
(run by lint in CI) rejects them before anything is packed. Keep only
the genuinely pack-time part - stripping dependencies / devDependencies
from the published manifest of the bundled TS CLI. The strip never
touches optionalDependencies, so it behaves identically for every pnpm
version and the v12 wrapper manifests pass through with their natives
intact.

Unblocks the staged wrapper publish in #12804.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants