Skip to content

Commit f49fef3

Browse files
pranavjain97mohammadalfaiyazbitgo
authored andcommitted
ci(release): verify shrinkwrap installs on node 20 before publishing bitgo
Adds a pre-publish gate between the siblings publish (pass 1) and the bitgo publish (pass 2): npm pack triggers the shrinkwrap generator via prepack, then we install the resulting tarball on Node 20 with engine-strict=true. Any transitive pinned by the shrinkwrap that violates engines (like sanitize-html@2.17.6 in WCN-2091) fails the release before the bad bitgo tarball reaches npm. Runs after pass 1 because the generator resolves newly-published siblings from the registry. If it fails, siblings are on npm but bitgo isn't -- fix and re-run in recovery-mode. Skipped in dry-run since siblings aren't published there. TICKET: WCN-2098
1 parent 3c67ddd commit f49fef3

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

.github/workflows/npmjs-release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,51 @@ jobs:
307307
env:
308308
NPM_CONFIG_PROVENANCE: true
309309

310+
# WCN-2091: fail the release BEFORE bitgo publishes if the shrinkwrap it
311+
# would ship pins any transitive that violates our declared engines (Node
312+
# >=20). Runs after pass 1 because the shrinkwrap generator resolves
313+
# newly-published siblings from the registry. Pack + install here, not
314+
# --package-lock-only, so `engine-strict=true` actually validates every
315+
# frozen entry's engines. If this fails, siblings are already on npm but
316+
# bitgo isn't — fix the shrinkwrap issue and re-run in recovery-mode.
317+
- name: Pre-publish shrinkwrap check — pack bitgo tarball
318+
if: inputs.dry-run == false
319+
env:
320+
BITGO_GENERATE_SHRINKWRAP: true
321+
run: |
322+
mkdir -p "$RUNNER_TEMP/tarballs"
323+
(cd modules/bitgo && npm pack --pack-destination "$RUNNER_TEMP/tarballs/")
324+
tarball="$(ls "$RUNNER_TEMP/tarballs"/*.tgz | head -1)"
325+
echo "PREPUB_TARBALL=$tarball" >> "$GITHUB_ENV"
326+
echo "Packed: $tarball"
327+
328+
- name: Pre-publish shrinkwrap check — setup Node 20
329+
if: inputs.dry-run == false
330+
uses: actions/setup-node@v6
331+
with:
332+
node-version: '20.x'
333+
334+
- name: Pre-publish shrinkwrap check — install tarball on Node 20 with engine-strict
335+
if: inputs.dry-run == false
336+
run: |
337+
workdir="$(mktemp -d)"
338+
cd "$workdir"
339+
echo "engine-strict=true" > .npmrc
340+
npm init -y >/dev/null
341+
echo "Verifying $PREPUB_TARBALL installs on $(node --version) with engine-strict=true"
342+
if ! npm install "$PREPUB_TARBALL" --no-audit --no-fund --ignore-scripts 2>install.log; then
343+
echo "::error::Pre-publish shrinkwrap check FAILED — bitgo tarball cannot be installed on Node 20 with engine-strict. Fix before publishing."
344+
cat install.log
345+
exit 1
346+
fi
347+
echo "✅ bitgo tarball installs cleanly on $(node --version) with engine-strict."
348+
349+
- name: Pre-publish shrinkwrap check — restore release Node version
350+
if: inputs.dry-run == false
351+
uses: actions/setup-node@v6
352+
with:
353+
node-version-file: ".nvmrc"
354+
310355
- name: Publish bitgo (pass 2)
311356
if: inputs.dry-run == false
312357
run: |

0 commit comments

Comments
 (0)