run `npm stage publish` instead of `npm publish` in changesets by phryneas · Pull Request #13245 · apollographql/apollo-client · GitHub
Skip to content

run npm stage publish instead of npm publish in changesets - #13245

Merged
jerelmiller merged 2 commits into
mainfrom
pr/publish-staged
May 27, 2026
Merged

jerelmiller merged 2 commits into
mainfrom
pr/publish-staged

Conversation

@phryneas

@phryneas phryneas commented May 27, 2026 •

Copy link
Copy Markdown
Member

There's no real workflow around changesets and npm staged publishing yet - this is discussed in changesets/changesets#2025.

So far, this will just run npm stage publish instead of npm publish, but already create tags and everything, before we approve it in the npm CLI or website. If we reject, a version number would be kinda "burned". But it feels like a good start.

Summary by CodeRabbit

  • Chores
    • Updated Node.js runtime from version 20 to version 24 in CI/CD workflows.
    • Upgraded npm to version 11.15.0 in the release pipeline.
    • Enhanced build and release process configurations with updated tooling settings.

Review Change Stack

@phryneas
phryneas requested a review from jerelmiller May 27, 2026 14:23
@apollo-librarian

apollo-librarian Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

@changeset-bot

changeset-bot Bot commented May 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e051235

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented May 27, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • release-*

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 1a9ee8d7-144e-4161-996c-eabdcfaae403

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

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 and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented May 27, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/apollographql/apollo-client/@apollo/client@13245

commit: e051235

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.

Pull request overview

This PR updates the Changesets-based release flow to use npm’s staged publishing (npm stage publish) instead of immediately publishing (npm publish), enabling an approval step after tags/releases are created.

Changes:

  • Adds a PATH-injected npm shim that rewrites npm publish to npm stage publish for Changesets publishing.
  • Updates the changeset-publish script to prepend the shim directory to PATH during changeset publish.
  • Updates the release workflow to upgrade npm to a version that supports staged publishing.

Reviewed changes

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

File Description
scripts/changesets/wrap-staged/npm New bash shim that rewrites npm publish to npm stage publish.
package.json Updates changeset-publish to run Changesets with the shim-injected PATH.
.gitignore Ensures the shim file named npm isn’t ignored by the existing npm ignore rule.
.github/workflows/release.yml Installs a newer npm version required for npm stage publish before running the release action.

Comment on lines +10 to +17
export PATH="${PATH#*:}"

if [ "${1:-}" = "publish" ]; then
shift
exec npm stage publish "$@"
fi

exec npm "$@"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah no, we don't need that for a stopgap 😅

Comment thread package.json
"docmodel": "npm run clean && node config/build.ts --step=prepareDist --step=addExports --step=typescript --step=inlineInheritDoc --step=deprecateInternals && node config/apiExtractor.ts --main-only --generate docModel",
"changeset-check": "changeset status --verbose --since=origin/main",
"changeset-publish": "npm pkg set 'workspaces[0]'=dist && npm run build && changeset publish",
"changeset-publish": "npm pkg set 'workspaces[0]'=dist && npm run build && PATH=\"$PWD/scripts/changesets/wrap-staged:$PATH\" changeset publish",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Wtf. If the npm version is wrong you get an error message 🤷

@phryneas
phryneas changed the base branch from pr/update-knip-node to main May 27, 2026 14:43

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@scripts/changesets/wrap-staged/npm`:
- Line 10: The export line export PATH="${PATH#*:}" can yield an empty PATH if
PATH is unset/empty; change it to defensively handle that case by either
wrapping it in a conditional that only updates PATH when PATH is non-empty
(e.g., check [ -n "$PATH" ] around the export) or use parameter expansion with a
safe default value for PATH so that PATH is never set to an empty string; update
the export PATH="${PATH#*:}" occurrence accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: ca936f72-a7ff-4813-a399-31b0ff63ac3d

📥 Commits

Reviewing files that changed from the base of the PR and between fc379af and e051235.

📒 Files selected for processing (5)
  • .github/workflows/knip.yml
  • .github/workflows/release.yml
  • .gitignore
  • package.json
  • scripts/changesets/wrap-staged/npm

# PATH entry, so we pop that entry to find the real npm.
set -euo pipefail

export PATH="${PATH#*:}"

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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Potential edge case: PATH could become empty.

The pattern ${PATH#*:} removes the prefix up to and including the first colon. If PATH contains no colon (e.g., if the original PATH was empty when prepended in package.json), this would result in an empty string, causing the npm command to fail.

While unlikely in CI environments, consider a more defensive pattern:

🛡️ Defensive PATH handling
-export PATH="${PATH#*:}"
+# Remove the first directory from PATH (the shim directory)
+export PATH="${PATH#*:}"
+if [ -z "$PATH" ]; then
+  echo "Error: PATH became empty after removing shim directory" >&2
+  exit 1
+fi

Or use a more explicit approach:

-export PATH="${PATH#*:}"
+# Remove the shim directory (first entry) from PATH
+IFS=':' read -ra path_array <<< "$PATH"
+export PATH="$(IFS=:; echo "${path_array[*]:1}")"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
🤖 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 `@scripts/changesets/wrap-staged/npm` at line 10, The export line export
PATH="${PATH#*:}" can yield an empty PATH if PATH is unset/empty; change it to
defensively handle that case by either wrapping it in a conditional that only
updates PATH when PATH is non-empty (e.g., check [ -n "$PATH" ] around the
export) or use parameter expansion with a safe default value for PATH so that
PATH is never set to an empty string; update the export PATH="${PATH#*:}"
occurrence accordingly.

@github-actions github-actions Bot added the auto-cleanup 🤖 label May 27, 2026
@jerelmiller
jerelmiller merged commit 189d166 into main May 27, 2026
58 of 59 checks passed
@jerelmiller
jerelmiller deleted the pr/publish-staged branch May 27, 2026 20:53
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Sep 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants