Skip to content

ci: gate the pacquet release publish job behind the release environment - #12641

Merged
zkochan merged 1 commit into
pnpm:mainfrom
YESHYUNGSEOK:ci/pacquet-release-env-gate
Jun 25, 2026
Merged

zkochan merged 1 commit into
pnpm:mainfrom
YESHYUNGSEOK:ci/pacquet-release-env-gate

Conversation

@YESHYUNGSEOK

@YESHYUNGSEOK YESHYUNGSEOK commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

pacquet-release-to-npm.yml can be triggered via workflow_dispatch. Its publish job uses npm
OIDC trusted publishing to publish the pacquet, @pnpm/pacquet, and pnpm-pacquet packages
(plus the per-target sub-packages). The job had no environment: release gate, so any
collaborator with write access could publish these packages to npm via a manual dispatch without
reviewer approval — unlike release.yml, which gates its publishing job.

This adds environment: release to the publish job. The build job produces no externally
visible artifacts and is intentionally left ungated so the matrix legs are not blocked on approval.

Squash Commit Body

pacquet-release-to-npm.yml can be triggered via workflow_dispatch. Its publish job uses npm OIDC
trusted publishing to publish the pacquet, `@pnpm/pacquet`, and pnpm-pacquet packages. It had no
environment gate, so any collaborator with write access could publish to npm via a manual
dispatch without reviewer approval.

Add an environment: release gate to the publish job (the build job produces no externally
visible artifacts and is intentionally left ungated), matching the protection used by release.yml.

Checklist

  • Added or updated tests — n/a; CI workflow permission gate with no unit-testable surface.
  • Updated the documentation if needed — n/a.

(No changeset: no published package changes. CI-only change.)


Written by an agent (Claude Code, claude-opus-4-8).

Summary by CodeRabbit

  • Chores
    • Updated the release publishing workflow to use a dedicated release environment for npm publishing.

pacquet-release-to-npm.yml can be triggered via workflow_dispatch. Its publish job uses npm OIDC
trusted publishing to publish the pacquet, `@pnpm/pacquet`, and pnpm-pacquet packages. It had no
environment gate, so any collaborator with write access could publish to npm via a manual
dispatch without reviewer approval.

Add an environment: release gate to the publish job (the build job produces no externally
visible artifacts and is intentionally left ungated), matching the protection used by release.yml.

Co-authored-by: Claude <[email protected]>
@YESHYUNGSEOK
YESHYUNGSEOK requested a review from zkochan as a code owner June 25, 2026 02:14
@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 08d18636-4efc-4026-9f08-f87840ed74cf

📥 Commits

Reviewing files that changed from the base of the PR and between 54c5c0e and eb089c5.

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

📝 Walkthrough

Walkthrough

The npm release workflow now runs its publish job in the GitHub Environment named release.

Changes

Release workflow environment binding

Layer / File(s) Summary
Publish job environment
.github/workflows/pacquet-release-to-npm.yml
The publish job now declares environment: release.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • pnpm/pnpm#11652: Also changes .github/workflows/pacquet-release-to-npm.yml and the release/publish flow in the same workflow.

Suggested labels

product: pacquet

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Gate pacquet npm publish job behind the protected release environment
⚙️ Configuration changes 🕐 Less than 10 minutes

Grey Divider

Description

• Add a GitHub Environment gate to the pacquet npm publish job.
• Prevent manual workflow_dispatch publishes without release reviewer approval.
• Keep the build matrix ungated since it produces no external artifacts.
Diagram

graph TD
  A(["workflow_dispatch: pacquet-release-to-npm"]) --> B["build job"] --> C["publish job"] --> D{{"GitHub Env: release"}} --> E[("npm registry")]
  subgraph Legend
    direction LR
    _wf(["Workflow trigger"]) ~~~ _job["Job"] ~~~ _env{{"Protected environment"}} ~~~ _reg[("External registry")]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Remove workflow_dispatch and publish only on release/tag events
  • ➕ Eliminates ad-hoc manual publishing paths entirely
  • ➕ Makes publishing intent auditable via tags/releases
  • ➖ Reduces operational flexibility for re-publishing/retries
  • ➖ May require additional tooling/process for exceptional cases
2. Split publish into a dedicated workflow callable only via workflow_call
  • ➕ Centralizes publishing policy in one workflow entrypoint
  • ➕ Can constrain which workflows/repos can invoke publishing
  • ➖ More workflow complexity and indirection
  • ➖ Still needs an environment gate (or equivalent) for approval

Recommendation: The chosen approach (adding environment: release to the publish job) is the most direct and aligns with existing release protections, while preserving the ability to run the build matrix without approval. Alternatives either reduce flexibility (removing manual dispatch) or increase workflow complexity (workflow_call) without materially improving protection beyond the environment gate.

Files changed (1) +1 / -0

Other (1) +1 / -0
pacquet-release-to-npm.ymlRequire release environment approval before npm publish job +1/-0

Require release environment approval before npm publish job

• Adds 'environment: release' to the 'publish' job so manual dispatches cannot publish packages without passing GitHub Environment protections (e.g., required reviewers). The 'build' job remains ungated to avoid approval blocking non-publishing work.

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

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jun 25, 2026
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Action required

1. Ref bypasses release gate 🐞 Bug ⛨ Security
Description
pacquet-release-to-npm.yml is workflow_dispatch and has no ref validation step (unlike
release.yml), so a write-access collaborator can dispatch and run a modified copy of this workflow
from another ref where the environment: release gate is removed. This undermines the intended
reviewer-approval control for npm publishing via OIDC.
Code

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

+    environment: release
Evidence
The workflow is manually dispatchable and contains no ref guard, while release.yml shows the
repo’s established pattern of adding an explicit ref validation step before doing release/publish
work.

.github/workflows/pacquet-release-to-npm.yml[7-14]
.github/workflows/pacquet-release-to-npm.yml[140-149]
.github/workflows/release.yml[7-25]

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

## Issue description
`pacquet-release-to-npm.yml` is manually dispatchable and currently relies on `environment: release` for approval gating, but it does not validate that the workflow is running from a trusted release ref. Because `workflow_dispatch` can be run against non-default refs, a collaborator with write access can run a modified workflow definition from another ref (e.g., with the `environment` gate removed) and bypass the intended approval gate.
## Issue Context
`release.yml` explicitly defends against this class of issue by validating the ref early and failing if it is not a version tag. `pacquet-release-to-npm.yml` should add a similar early validation (but for the default branch), and make the build/publish sequence depend on it.
## Fix Focus Areas
- .github/workflows/pacquet-release-to-npm.yml[7-22]
- .github/workflows/pacquet-release-to-npm.yml[22-65]
- .github/workflows/pacquet-release-to-npm.yml[140-149]
## Proposed fix
1. Add a new job (e.g. `validate-release-ref`) at the start of the workflow with `permissions: {}`.
2. In that job, check `${GITHUB_REF}` equals the repository default branch ref (e.g. `refs/heads/${{ github.event.repository.default_branch }}`) and fail otherwise.
3. Make `build` depend on this validation job (so the expensive matrix doesn’t run on untrusted refs), and keep `publish` depending on `build` (transitively enforcing the validation).

ⓘ 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 eb089c5

Results up to commit eb089c5


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


Action required
1. Ref bypasses release gate 🐞 Bug ⛨ Security
Description
pacquet-release-to-npm.yml is workflow_dispatch and has no ref validation step (unlike
release.yml), so a write-access collaborator can dispatch and run a modified copy of this workflow
from another ref where the environment: release gate is removed. This undermines the intended
reviewer-approval control for npm publishing via OIDC.
Code

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

+    environment: release
Evidence
The workflow is manually dispatchable and contains no ref guard, while release.yml shows the
repo’s established pattern of adding an explicit ref validation step before doing release/publish
work.

.github/workflows/pacquet-release-to-npm.yml[7-14]
.github/workflows/pacquet-release-to-npm.yml[140-149]
.github/workflows/release.yml[7-25]

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

## Issue description
`pacquet-release-to-npm.yml` is manually dispatchable and currently relies on `environment: release` for approval gating, but it does not validate that the workflow is running from a trusted release ref. Because `workflow_dispatch` can be run against non-default refs, a collaborator with write access can run a modified workflow definition from another ref (e.g., with the `environment` gate removed) and bypass the intended approval gate.

## Issue Context
`release.yml` explicitly defends against this class of issue by validating the ref early and failing if it is not a version tag. `pacquet-release-to-npm.yml` should add a similar early validation (but for the default branch), and make the build/publish sequence depend on it.

## Fix Focus Areas
- .github/workflows/pacquet-release-to-npm.yml[7-22]
- .github/workflows/pacquet-release-to-npm.yml[22-65]
- .github/workflows/pacquet-release-to-npm.yml[140-149]

## Proposed fix
1. Add a new job (e.g. `validate-release-ref`) at the start of the workflow with `permissions: {}`.
2. In that job, check `${GITHUB_REF}` equals the repository default branch ref (e.g. `refs/heads/${{ github.event.repository.default_branch }}`) and fail otherwise.
3. Make `build` depend on this validation job (so the expensive matrix doesn’t run on untrusted refs), and keep `publish` depending on `build` (transitively enforcing the validation).

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


Qodo Logo

publish:
name: Publish
runs-on: ubuntu-latest
environment: release

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Ref bypasses release gate 🐞 Bug ⛨ Security

pacquet-release-to-npm.yml is workflow_dispatch and has no ref validation step (unlike
release.yml), so a write-access collaborator can dispatch and run a modified copy of this workflow
from another ref where the environment: release gate is removed. This undermines the intended
reviewer-approval control for npm publishing via OIDC.
Agent Prompt
## Issue description
`pacquet-release-to-npm.yml` is manually dispatchable and currently relies on `environment: release` for approval gating, but it does not validate that the workflow is running from a trusted release ref. Because `workflow_dispatch` can be run against non-default refs, a collaborator with write access can run a modified workflow definition from another ref (e.g., with the `environment` gate removed) and bypass the intended approval gate.

## Issue Context
`release.yml` explicitly defends against this class of issue by validating the ref early and failing if it is not a version tag. `pacquet-release-to-npm.yml` should add a similar early validation (but for the default branch), and make the build/publish sequence depend on it.

## Fix Focus Areas
- .github/workflows/pacquet-release-to-npm.yml[7-22]
- .github/workflows/pacquet-release-to-npm.yml[22-65]
- .github/workflows/pacquet-release-to-npm.yml[140-149]

## Proposed fix
1. Add a new job (e.g. `validate-release-ref`) at the start of the workflow with `permissions: {}`.
2. In that job, check `${GITHUB_REF}` equals the repository default branch ref (e.g. `refs/heads/${{ github.event.repository.default_branch }}`) and fail otherwise.
3. Make `build` depend on this validation job (so the expensive matrix doesn’t run on untrusted refs), and keep `publish` depending on `build` (transitively enforcing the validation).

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

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

Copy link
Copy Markdown

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

@YESHYUNGSEOK

Copy link
Copy Markdown
Contributor Author

Thanks @qodo — re: Ref bypasses release gate (no ref validation): same disposition as the equivalent finding on the pnpr release workflow (#12640). The environment: release approval added here already requires human review before the npm OIDC publish, so an attacker-branch dispatch is surfaced to the approver. A ref allowlist step and/or the environment's deployment branches setting are the canonical hardening and are reasonable follow-ups; I left them out of this scoped PR to avoid guessing the intended release ref and breaking the flow.


Written by an agent (Claude Code, claude-opus-4-8).

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

Copy link
Copy Markdown

Thanks @qodo — re: Ref bypasses release gate (no ref validation): same disposition as the equivalent finding on the pnpr release workflow (#12640). The environment: release approval added here already requires human review before the npm OIDC publish, so an attacker-branch dispatch is surfaced to the approver. A ref allowlist step and/or the environment's deployment branches setting are the canonical hardening and are reasonable follow-ups; I left them out of this scoped PR to avoid guessing the intended release ref and breaking the flow.


Written by an agent (Claude Code, claude-opus-4-8).

Agreed — for this PR, environment: release does add a human approval gate before the npm OIDC publish, so the immediate bypass concern is materially reduced.

  • A ref allowlist or the environment’s deployment-branches setting would still be a good defense-in-depth follow-up.
  • Keeping that out of this scoped PR is reasonable if the intended release ref isn’t fully settled yet.

@zkochan

zkochan commented Jun 25, 2026

Copy link
Copy Markdown
Member

again, why 3 PRs for the same thing?

@zkochan
zkochan merged commit 114e4f5 into pnpm:main Jun 25, 2026
25 checks passed
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