Skip to content

Commit 189d166

Browse files
authored
run npm stage publish instead of npm publish in changesets (#13245)
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. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## 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_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/apollographql/apollo-client/pull/13245?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent fc379af commit 189d166

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ jobs:
5050
# deliberately not using a cache for action with elevated permissions, see https://tanstack.com/blog/npm-supply-chain-compromise-postmortem
5151
package-manager-cache: false
5252

53+
# `npm stage publish` (https://docs.npmjs.com/staged-publishing) requires
54+
# npm >= 11.15.0. Node 24.x currently bundles at most 11.13.0, so upgrade.
55+
- run: npm install -g npm@11.15.0
56+
5357
- run: npm ci
5458

5559
- name: "[main] Create release PR or publish to npm + GitHub"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ test-lib
4646
dist
4747
npm
4848
!flow-typed/npm
49+
!scripts/changesets/wrap-staged/npm
4950

5051
# Unpublished output from @apollo/client build, like bundlesize artifacts
5152
temp/

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
"typedoc": "typedoc src/core/index.ts --json docs/public/docs.json",
111111
"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",
112112
"changeset-check": "changeset status --verbose --since=origin/main",
113-
"changeset-publish": "npm pkg set 'workspaces[0]'=dist && npm run build && changeset publish",
113+
"changeset-publish": "npm pkg set 'workspaces[0]'=dist && npm run build && PATH=\"$PWD/scripts/changesets/wrap-staged:$PATH\" changeset publish",
114114
"changeset-version": "changeset version && npm i",
115115
"update-size-limits": "size-limit --json | jq '. | map(select(.sizeLimit) | { key: .name, value: .size}) | from_entries' | tee .new-size-limits.json; mv .new-size-limits.json .size-limits.json",
116116
"knip": "knip --tags=-knipignore",

scripts/changesets/wrap-staged/npm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
# Shim that rewrites `npm publish ...` to `npm stage publish ...`
3+
# (https://docs.npmjs.com/staged-publishing) and forwards every other
4+
# invocation to the real npm unchanged.
5+
#
6+
# Invoked via PATH lookup with its own directory prepended as the first
7+
# PATH entry, so we pop that entry to find the real npm.
8+
set -euo pipefail
9+
10+
export PATH="${PATH#*:}"
11+
12+
if [ "${1:-}" = "publish" ]; then
13+
shift
14+
exec npm stage publish "$@"
15+
fi
16+
17+
exec npm "$@"

0 commit comments

Comments
 (0)