Skip to content

Commit 3d7a35e

Browse files
committed
fix(release): use pnpm pack to normalise workspace:* deps before npm publish
npm publish <dir> does not transform pnpm workspace:* protocol references to real semver. This caused @cfxdevkit/core to be published with "@cfxdevkit/contracts": "workspace:*" in its dependencies, which breaks any bundler (Sandpack, Vite, webpack) that tries to resolve the package. Fix: use pnpm pack -C <dir> to produce a tarball (pnpm normalises workspace:* to the concrete version at pack time), then npm publish the tarball so the OIDC token exchange still works.
1 parent 63757e7 commit 3d7a35e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,24 @@ jobs:
121121
npm config delete "//registry.npmjs.org/:_authToken" || true
122122
123123
# ── 1. Publish all @cfxdevkit/* library packages ───────────────────────
124-
# IMPORTANT: Use `npm publish` (not `pnpm publish`) so the npm CLI can
125-
# automatically exchange the GitHub OIDC token for a short-lived npm
126-
# credential. `pnpm publish` does NOT trigger the OIDC token exchange,
127-
# which causes "Access token expired" + E404 even when trusted publishing
128-
# is correctly configured on npmjs.com.
124+
# Use `pnpm pack` to create the tarball — this normalises workspace:*
125+
# dependency references (e.g. "@cfxdevkit/contracts": "workspace:*") to
126+
# real semver before the tarball is created, so the published package.json
127+
# is clean. Then hand the tarball to `npm publish` so the OIDC token
128+
# exchange still happens via the npm CLI (pnpm publish does not trigger it).
129129
- name: Publish @cfxdevkit/* packages
130130
run: |
131131
set -e
132132
failed=''
133133
for pkg_dir in packages/*/; do
134134
pkg_name=$(node -p "require('./${pkg_dir}package.json').name")
135135
echo "\n--- Publishing ${pkg_name} ---"
136-
if ! npm publish "${pkg_dir}" --access public; then
136+
tarball=$(pnpm pack -C "${pkg_dir}" --pack-destination "$PWD" 2>/dev/null | tail -1)
137+
if ! npm publish "${tarball}" --access public; then
137138
echo "::error::Failed to publish ${pkg_name}"
138139
failed="${failed} ${pkg_name}"
139140
fi
141+
rm -f "${tarball}"
140142
done
141143
if [ -n "$failed" ]; then
142144
echo "::error::The following packages failed to publish:${failed}"

0 commit comments

Comments
 (0)