Skip to content

Commit 8e6fc83

Browse files
SawyerHoodclaude
andauthored
Publish the nightly channel after a stable release (#1651)
## Problem A nightly version is `<next patch>-nightly.<run id>.<attempt>`, derived from the version on `main`. When we release `0.38.0`, the newest nightly is `0.37.1-nightly.*`, which is lower than `latest`. The nightly npm dist-tag and the `bb Nightly` desktop app therefore stay behind the stable release until the 3am cron. ## Change A non-dry `npm_tag=latest` run now refreshes the nightly channel from the same release commit. - New `publish-nightly` job. It runs only for a non-dry `latest` dispatch, after `publish` succeeds. It derives the next nightly version from the release commit, publishes it under the `nightly` dist-tag, and verifies the registry. It runs `smoke:tarball` first, because `bb-app` has no `prepack` hook and its `files` list ships built output, so a fresh runner must build before it packs. It skips typecheck and unit tests, because `publish` ran them on this same commit and only the version string differs. - The nightly desktop build jobs take the version from either npm job: `needs.publish-nightly.outputs.version || needs.publish.outputs.version`. Their `if` uses `!cancelled()`, because `publish-nightly` is skipped on the scheduled and manual nightly paths and a skipped need would otherwise skip them. - Both npm publishes that move the `nightly` dist-tag share one job-level concurrency group, `publish-nightly-npm`, so the cron and a release run cannot move that tag at the same time. A stable release publishes `latest`, so it takes a per-run group and never queues behind the cron. - `nightly-desktop-publish` gets its own concurrency group. The workflow-level group splits `nightly` from `ref`, so a release run and the cron could reach the moving `desktop-nightly` release at the same time. That job deletes every asset before upload, so the race could leave one platform's binaries missing. - `docs/bb-release-process.md` and `apps/desktop/README.md` describe the new step. The nightly jobs run after the stable publish succeeds, so a nightly failure cannot affect the release that already shipped. ## Tests - Parsed the workflow YAML and confirmed the job graph, the `if` expressions, and the `needs` lists. - No unit tests: the change is GitHub Actions job wiring. `prepare-nightly-version.mjs` and `bump-version.mjs` are unchanged. ## Risks - A `latest` run grows from about 7 minutes to about 30 minutes, because it now also builds the signed macOS and Linux nightly desktop apps. Measured from recent runs: `Publish bb-app` 7m, macOS desktop 14m, Linux desktop 4m, desktop publish under 1m. The stable npm publish still completes about 7 minutes in, so users do not get the release later. - The `npm-release` environment gate applies to `publish-nightly` too, so an approval-gated setup asks a second time. - The full path only runs on a real release dispatch, so the first live exercise is the next stable release. > AGENT GENERATED: by Claude Opus 5 --------- Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
1 parent 641380f commit 8e6fc83

3 files changed

Lines changed: 179 additions & 6 deletions

File tree

‎.github/workflows/publish-bb-app.yml‎

Lines changed: 161 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ jobs:
5656
id-token: write
5757
outputs:
5858
version: ${{ steps.release.outputs.version }}
59+
# Every publish that moves the `nightly` dist-tag shares one group, so the
60+
# cron and a release run's publish-nightly job cannot move that tag at the
61+
# same time. A stable release publishes `latest` here instead, so it takes a
62+
# per-run group and never waits on the cron.
63+
concurrency:
64+
group: ${{ (github.event_name == 'schedule' || inputs.npm_tag == 'nightly') && 'publish-nightly-npm' || format('publish-bb-app-npm-{0}', github.run_id) }}
65+
cancel-in-progress: false
5966

6067
steps:
6168
- name: Require main branch
@@ -224,6 +231,125 @@ jobs:
224231
echo "- commit: \`${GITHUB_SHA}\`"
225232
} >> "$GITHUB_STEP_SUMMARY"
226233
234+
# A stable release moves `latest` past the newest nightly, because a nightly
235+
# version is the next patch of whatever main held the night before. The
236+
# nightly channel would then sit behind `latest` until the next 3am cron. This
237+
# job republishes the nightly channel from the same release commit, at
238+
# <next patch>-nightly.<run id>.<attempt>, so nightly stays ahead of the
239+
# release it was cut from. It runs only for a real `latest` publish, and a
240+
# failure here cannot roll back the stable release that already shipped.
241+
publish-nightly:
242+
name: Publish bb-app nightly after the release
243+
if: ${{ github.event_name == 'workflow_dispatch' && inputs.npm_tag == 'latest' && inputs.dry_run == false }}
244+
needs: publish
245+
runs-on: ubuntu-latest
246+
timeout-minutes: 30
247+
environment: npm-release
248+
permissions:
249+
contents: read
250+
id-token: write
251+
outputs:
252+
version: ${{ steps.nightly_version.outputs.version }}
253+
# Shares the publish job's nightly group. See that job for why.
254+
concurrency:
255+
group: publish-nightly-npm
256+
cancel-in-progress: false
257+
258+
steps:
259+
- name: Checkout repository
260+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
261+
262+
- name: Set up pnpm
263+
uses: pnpm/action-setup@0977fd99725f1db4007ccb2928dbb4e90d06cc86 # v6.0.10
264+
with:
265+
version: 9.15.0
266+
run_install: false
267+
268+
- name: Set up Node.js
269+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
270+
with:
271+
node-version: 24
272+
registry-url: https://registry.npmjs.org
273+
274+
- name: Ensure npm supports trusted publishing
275+
run: |
276+
npm_version="$(npm --version)"
277+
node - "$npm_version" <<'NODE' || npm install --global npm@latest
278+
const version = process.argv[2];
279+
const [major, minor, patch] = version.split(".").map(Number);
280+
const supported =
281+
major > 11 ||
282+
(major === 11 && (minor > 5 || (minor === 5 && patch >= 1)));
283+
process.exit(supported ? 0 : 1);
284+
NODE
285+
npm --version
286+
287+
- name: Install dependencies
288+
run: pnpm install --frozen-lockfile
289+
290+
- name: Prepare nightly version
291+
id: nightly_version
292+
run: |
293+
set -euo pipefail
294+
295+
# Runs after the release commit is checked out, so the derived
296+
# version is the next patch above the version just published.
297+
nightly_version="$(node scripts/prepare-nightly-version.mjs)"
298+
echo "PACKAGE_VERSION=${nightly_version}" >> "$GITHUB_ENV"
299+
echo "version=${nightly_version}" >> "$GITHUB_OUTPUT"
300+
echo "Prepared bb-app and desktop version ${nightly_version}."
301+
302+
# bb-app has no prepack hook and its `files` list ships built output, so
303+
# `npm publish` packs whatever is on disk. This job runs on a fresh
304+
# runner, so it must build before it packs. smoke:tarball depends on
305+
# build and also proves the packed tarball runs at the nightly version.
306+
- name: Smoke bb-app tarball
307+
run: pnpm exec turbo run smoke:tarball --filter=bb-app --force --output-logs=new-only
308+
309+
- name: Preview npm package
310+
working-directory: packages/bb-app
311+
run: npm pack --dry-run
312+
313+
# No typecheck or unit tests here: the publish job ran them on this same
314+
# commit and only the version string differs.
315+
- name: Publish to npm
316+
working-directory: packages/bb-app
317+
run: npm publish --tag nightly
318+
319+
- name: Verify npm release
320+
run: |
321+
for attempt in 1 2 3 4 5 6 7 8 9 10 11 12; do
322+
package_version="$(npm view "bb-app@$PACKAGE_VERSION" version --json 2>/tmp/bb-app-version.err || true)"
323+
tag_version="$(npm view "bb-app@nightly" version --json 2>/tmp/bb-app-tag.err || true)"
324+
325+
if [ "$package_version" = "\"$PACKAGE_VERSION\"" ] && [ "$tag_version" = "\"$PACKAGE_VERSION\"" ]; then
326+
echo "$package_version"
327+
npm view bb-app version dist-tags --json
328+
exit 0
329+
fi
330+
331+
echo "Registry has not exposed bb-app@$PACKAGE_VERSION on tag nightly yet; retrying ($attempt/12)."
332+
cat /tmp/bb-app-version.err || true
333+
cat /tmp/bb-app-tag.err || true
334+
sleep 10
335+
done
336+
337+
echo "::error::Timed out waiting for bb-app@$PACKAGE_VERSION to appear on npm tag nightly."
338+
exit 1
339+
340+
- name: Summarize the nightly release
341+
env:
342+
RELEASE_VERSION: ${{ needs.publish.outputs.version }}
343+
run: |
344+
{
345+
echo "## bb-app nightly after the release"
346+
echo
347+
echo "- released version: \`$RELEASE_VERSION\`"
348+
echo "- nightly version: \`$PACKAGE_VERSION\`"
349+
echo "- npm tag: \`nightly\`"
350+
echo "- commit: \`${GITHUB_SHA}\`"
351+
} >> "$GITHUB_STEP_SUMMARY"
352+
227353
# Rides the same release train as bb-app but stays independent of it: the SDK
228354
# version is settled in the repo (packages/domain/src/plugin-sdk-version.ts,
229355
# mirrored in packages/plugin-sdk/package.json), never computed here. Every
@@ -362,8 +488,18 @@ jobs:
362488
363489
nightly-desktop-macos:
364490
name: Build bb Nightly desktop (macOS)
365-
if: ${{ github.event_name == 'schedule' || (inputs.npm_tag == 'nightly' && inputs.dry_run == false) }}
366-
needs: publish
491+
# `!cancelled()` is required because publish-nightly is skipped on the
492+
# scheduled and manual nightly paths, and a skipped need would otherwise
493+
# skip this job too.
494+
if: >-
495+
${{ !cancelled()
496+
&& needs.publish.result == 'success'
497+
&& (github.event_name == 'schedule'
498+
|| (inputs.npm_tag == 'nightly' && inputs.dry_run == false)
499+
|| needs.publish-nightly.result == 'success') }}
500+
needs:
501+
- publish
502+
- publish-nightly
367503
runs-on: macos-15
368504
timeout-minutes: 45
369505
outputs:
@@ -397,7 +533,10 @@ jobs:
397533
- name: Apply the nightly version
398534
id: nightly_version
399535
env:
400-
NIGHTLY_VERSION: ${{ needs.publish.outputs.version }}
536+
# publish-nightly holds the version on a release run; publish holds it
537+
# on the scheduled and manual nightly paths, where publish-nightly is
538+
# skipped and reports an empty version.
539+
NIGHTLY_VERSION: ${{ needs.publish-nightly.outputs.version || needs.publish.outputs.version }}
401540
run: |
402541
set -euo pipefail
403542
@@ -484,8 +623,16 @@ jobs:
484623

485624
nightly-desktop-linux:
486625
name: Build bb Nightly desktop (Linux)
487-
if: ${{ github.event_name == 'schedule' || (inputs.npm_tag == 'nightly' && inputs.dry_run == false) }}
488-
needs: publish
626+
# See the macOS job for why this condition uses `!cancelled()`.
627+
if: >-
628+
${{ !cancelled()
629+
&& needs.publish.result == 'success'
630+
&& (github.event_name == 'schedule'
631+
|| (inputs.npm_tag == 'nightly' && inputs.dry_run == false)
632+
|| needs.publish-nightly.result == 'success') }}
633+
needs:
634+
- publish
635+
- publish-nightly
489636
# Pinned rather than ubuntu-latest so the glibc the AppImage links against
490637
# changes only when we choose it: the build machine's glibc sets the
491638
# minimum distro version users need.
@@ -518,7 +665,8 @@ jobs:
518665
- name: Apply the nightly version
519666
id: nightly_version
520667
env:
521-
NIGHTLY_VERSION: ${{ needs.publish.outputs.version }}
668+
# See the macOS job for why the version comes from either npm job.
669+
NIGHTLY_VERSION: ${{ needs.publish-nightly.outputs.version || needs.publish.outputs.version }}
522670
run: |
523671
set -euo pipefail
524672
@@ -576,6 +724,13 @@ jobs:
576724
timeout-minutes: 20
577725
permissions:
578726
contents: write
727+
# The workflow-level group splits nightly from ref, so a release run and the
728+
# cron can reach this job at the same time. Both delete every asset on the
729+
# moving release and upload their own, so a race can leave one platform's
730+
# binaries missing. Serialize the reset instead.
731+
concurrency:
732+
group: publish-nightly-desktop
733+
cancel-in-progress: false
579734

580735
steps:
581736
- name: Checkout repository

‎apps/desktop/README.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,11 @@ To publish or dry-run the channel manually from `main`, dispatch the same
176176
workflow with `npm_tag=nightly`. A non-dry run publishes both npm and desktop;
177177
a dry run validates only the npm package path.
178178

179+
A stable release also refreshes the channel. A non-dry `npm_tag=latest` run
180+
publishes the release, then derives the next nightly version from the release
181+
commit and publishes npm and desktop nightly again. Without this step the
182+
nightly channel stays below `latest` until the next scheduled run.
183+
179184
The nightly desktop is a separate installation:
180185

181186
- product name: `bb Nightly`

‎docs/bb-release-process.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ gh workflow run publish-bb-app.yml \
3838

3939
Set `dry_run=false` to publish both npm and the signed desktop nightly.
4040

41+
A stable release refreshes the nightly channel too. A nightly version is the
42+
next patch above the version on `main`, so a new `latest` release moves ahead of
43+
the newest nightly. To prevent a nightly channel that is older than `latest`, a
44+
non-dry `npm_tag=latest` run adds a `publish-nightly` job. That job derives
45+
`<next patch>-nightly.<run id>.<attempt>` from the release commit, publishes it
46+
under the `nightly` dist-tag, and the same desktop jobs then rebuild and move
47+
the `desktop-nightly` release. The nightly jobs run after the stable publish
48+
succeeds, so a nightly failure cannot affect the release that already shipped.
49+
4150
## Release Policy
4251

4352
- Publish only from `main`.
@@ -155,6 +164,10 @@ gh workflow run publish-bb-app.yml \
155164
-f dry_run=false
156165
```
157166

167+
This run publishes the release and then republishes the nightly channel from the
168+
same commit, so the run also builds the `bb Nightly` desktop app. Expect the run
169+
to take longer than the npm publish alone.
170+
158171
Use prerelease dist-tags such as `alpha` only when the user explicitly asks for
159172
a separate prerelease channel. npm Trusted Publishing authenticates
160173
`npm publish`, not post-publish tag edits, so the OIDC-only workflow can set one

0 commit comments

Comments
 (0)