Skip to content

Commit 5792572

Browse files
authored
Merge pull request #9424 from BitGo/WCN-1818-phase-2-pubish-in-multi-stages
fix: split publish into siblings-then-bitgo passes
2 parents 835483e + 860bb19 commit 5792572

2 files changed

Lines changed: 64 additions & 12 deletions

File tree

.github/workflows/npmjs-release.yml

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -295,26 +295,53 @@ jobs:
295295
- name: Verify all packages exist on npm
296296
uses: ./.github/actions/verify-npm-packages
297297

298-
- name: Publish new version
298+
# Version bump only — no publish. Separated from publishing (WCN-1818) so the
299+
# two-phase publish below can run identically whether this step just bumped
300+
# versions (normal path) or recovery-mode skipped it (rel/latest already
301+
# holds the versions to resume from).
302+
- name: Bump version
299303
if: ${{ inputs.dry-run == false && !inputs.recovery-mode }}
300304
run: |
301-
yarn lerna publish --sign-git-tag --sign-git-commit --include-merged-tags --conventional-commits --conventional-graduate --yes
305+
yarn lerna version --sign-git-tag --sign-git-commit --include-merged-tags --conventional-commits --conventional-graduate --yes
306+
307+
# Two-phase publish (WCN-1818): bitgo's `prepack` script resolves its
308+
# siblings from the registry, but a single combined `lerna publish` packs
309+
# every package's lifecycle hooks before uploading any of them — so bitgo
310+
# would try to resolve siblings that aren't live yet (this is what broke
311+
# `npm install bitgo` for every consumer, WCI-1200). Hold bitgo back
312+
# (private), publish siblings first, then restore and publish bitgo alone
313+
# once its siblings are actually resolvable. Runs identically for the
314+
# normal path (after the version bump above) and the recovery path (no
315+
# preceding bump) — `from-package` only publishes what's missing from npm
316+
# either way, so re-running is idempotent.
317+
- name: Hold back bitgo umbrella for the siblings publish pass
318+
if: inputs.dry-run == false
319+
run: npx tsx ./scripts/set-umbrella-publishable.ts false
320+
321+
- name: Publish siblings (pass 1)
322+
if: inputs.dry-run == false
323+
run: |
324+
# `from-package` reads each package.json's `version`, queries npm,
325+
# and publishes only versions missing from the registry.
326+
yarn lerna publish from-package --yes
302327
env:
303328
NPM_CONFIG_PROVENANCE: true
304-
# Tells bitgo's `prepack` script (scripts/generate-bitgo-shrinkwrap.ts) to
305-
# actually generate npm-shrinkwrap.json — kept opt-in so a plain local
306-
# `npm pack` doesn't force a network install of the full dependency tree.
307-
BITGO_GENERATE_SHRINKWRAP: true
308329

309-
- name: Publish missing versions (recovery)
310-
if: ${{ inputs.dry-run == false && inputs.recovery-mode }}
330+
- name: Restore bitgo umbrella for its own publish pass
331+
if: ${{ always() && inputs.dry-run == false }}
332+
run: npx tsx ./scripts/set-umbrella-publishable.ts true
333+
334+
- name: Publish bitgo (pass 2)
335+
if: inputs.dry-run == false
311336
run: |
312-
# `from-package` reads each package.json's `version`, queries npm,
313-
# and publishes only versions missing from the registry. No bump,
314-
# no tag, no git push.
315337
yarn lerna publish from-package --yes
316338
env:
317339
NPM_CONFIG_PROVENANCE: true
340+
# Tells bitgo's `prepack` script (scripts/generate-bitgo-shrinkwrap.ts) to
341+
# actually generate npm-shrinkwrap.json — kept opt-in so a plain local
342+
# `npm pack` doesn't force a network install of the full dependency tree.
343+
# Siblings published in the pass above are live on the registry by now,
344+
# so resolution succeeds.
318345
BITGO_GENERATE_SHRINKWRAP: true
319346

320347
- name: Verify recovery published the missing versions

.github/workflows/publish.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,39 @@ jobs:
100100
- name: Commit Local Changes
101101
run: git commit -am "Auto updated ${{ env.preid }} branch" --no-verify || echo "No changes to commit"
102102

103-
- name: Lerna Publish
103+
# Two-phase publish (WCN-1818): bitgo's `prepack` script resolves its siblings
104+
# from the registry, but a single combined `lerna publish` packs every
105+
# package's lifecycle hooks before uploading any of them — so bitgo would
106+
# try to resolve siblings that aren't live yet. Hold bitgo back (private),
107+
# publish siblings first, then restore and publish bitgo alone once its
108+
# siblings are actually resolvable.
109+
- name: Hold back bitgo umbrella for the siblings publish pass
110+
run: npx tsx ./scripts/set-umbrella-publishable.ts false
111+
112+
- name: Lerna Publish (siblings)
104113
# In recovery mode a stuck package's Rekor conflict fails this step outright; let it
105114
# continue so Verify Publish below still gets a chance to bump+retry that package.
106115
continue-on-error: ${{ inputs.recovery-mode }}
107116
run: yarn lerna publish from-package --preid ${{ env.preid }} --dist-tag ${{ env.preid }} --force-publish --yes --loglevel silly
108117
env:
109118
NPM_CONFIG_PROVENANCE: true
110119

120+
- name: Restore bitgo umbrella for its own publish pass
121+
if: always()
122+
run: npx tsx ./scripts/set-umbrella-publishable.ts true
123+
124+
- name: Lerna Publish (bitgo)
125+
# Siblings published above are now live on the registry, so bitgo's
126+
# `prepack` script (scripts/generate-bitgo-shrinkwrap.ts) can resolve them
127+
# for real. BITGO_GENERATE_SHRINKWRAP is set here (unlike historically on
128+
# this workflow) so alpha/beta actually exercises shrinkwrap generation
129+
# instead of silently no-oping on it.
130+
continue-on-error: ${{ inputs.recovery-mode }}
131+
run: yarn lerna publish from-package --preid ${{ env.preid }} --dist-tag ${{ env.preid }} --force-publish --yes --loglevel silly
132+
env:
133+
NPM_CONFIG_PROVENANCE: true
134+
BITGO_GENERATE_SHRINKWRAP: true
135+
111136
- name: Verify Publish
112137
run: npx tsx ./scripts/verify-release.ts ${{ env.preid }}
113138
env:

0 commit comments

Comments
 (0)