Skip to content

Commit 4219491

Browse files
t3dotggclaude
andcommitted
fix(release): the feed job tells a GitHub outage from a stale pointer
Council round 2: - A response body that fails to arrive no longer marks the pointer stale, and no longer blocks the pointer repair when it is the feed's body. - The job reports an unreadable feed and a hidden nightly as different failures, and publishes the update-feed release if someone drafted it. - Docs: the rollback steps cover a paused schedule and npm's nightly dist-tag, and the release order no longer says previews publish to npm. Co-Authored-By: Claude Fable 5.2 <[email protected]>
1 parent 1e54c55 commit 4219491

5 files changed

Lines changed: 70 additions & 31 deletions

File tree

‎.github/scripts/check-nightly-release.cjs‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,27 @@ async function readNightlyUpdateFeed({ github, context, fetch = globalThis.fetch
135135
if (!pointer.ok && pointer.status !== 404) {
136136
throw new Error(`The update-feed pointer answered HTTP ${pointer.status}.`);
137137
}
138-
const pointerTag = pointer.ok ? (await pointer.json().catch(() => null))?.tag_name : undefined;
139-
140-
// An unreadable feed leaves `feedNightly` unset, so the pointer is still repaired.
141-
const feed = await fetch(`${base}/releases.atom`).catch(() => undefined);
142-
const feedTags = feed?.ok
143-
? Array.from((await feed.text()).matchAll(/href="[^"]*\/releases\/tag\/([^"]+)"/g), (match) =>
144-
decodeURIComponent(match[1]),
145-
)
146-
: undefined;
147-
const feedNightly = feedTags?.find((tag) => /^v\d+\.\d+\.\d+-nightly\./.test(tag));
138+
let pointerTag;
139+
if (pointer.ok) {
140+
// A body that fails to arrive throws here; only one that is not JSON counts as malformed.
141+
const body = await pointer.text();
142+
try {
143+
pointerTag = JSON.parse(body)?.tag_name;
144+
} catch {}
145+
}
146+
147+
// An unreadable feed leaves `feedTags` unset, so the pointer is still repaired.
148+
let feedTags;
149+
try {
150+
const feed = await fetch(`${base}/releases.atom`);
151+
if (feed.ok) {
152+
feedTags = Array.from(
153+
(await feed.text()).matchAll(/href="[^"]*\/releases\/tag\/([^"]+)"/g),
154+
(match) => decodeURIComponent(match[1]),
155+
);
156+
}
157+
} catch {}
158+
const feedNightly = feedTags?.find((tag) => /^v?\d+\.\d+\.\d+-nightly\./.test(tag));
148159

149160
return { tag: latest.tagName, pointerTag, feedNightly, feedTags };
150161
}

‎.github/scripts/check-nightly-release.test.cjs‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ function updateFeedFixture({ feed, pointer }) {
261261
}
262262

263263
const missing = () => new Response("Not Found", { status: 404 });
264+
// HTTP 200, then the connection drops before the body arrives.
265+
const brokenBody = () =>
266+
new Response(new ReadableStream({ start: (controller) => controller.error(new Error("reset")) }));
264267
for (const [name, { feed, pointer }, expected] of [
265268
[
266269
"a nightly crowded out of the feed and a missing pointer",
@@ -277,6 +280,11 @@ for (const [name, { feed, pointer }, expected] of [
277280
{ feed: new Response("", { status: 503 }), pointer: Response.json(null) },
278281
{ pointerTag: undefined, feedNightly: undefined },
279282
],
283+
[
284+
"the pointer when the feed's body fails to arrive",
285+
{ feed: brokenBody(), pointer: Response.json({ tag_name: NEWEST }) },
286+
{ pointerTag: NEWEST, feedNightly: undefined },
287+
],
280288
]) {
281289
test(`update feed check reports ${name}`, async () => {
282290
const { tag, pointerTag, feedNightly } = await readNightlyUpdateFeed(
@@ -286,10 +294,12 @@ for (const [name, { feed, pointer }, expected] of [
286294
});
287295
}
288296

289-
test("update feed check does not call a pointer stale when GitHub fails to serve it", async () => {
290-
const options = updateFeedFixture({
291-
feed: atomFeed([NEWEST]),
292-
pointer: new Response("", { status: 503 }),
297+
for (const [name, pointer, error] of [
298+
["answers with an error", () => new Response("", { status: 503 }), /pointer answered HTTP 503/],
299+
["drops the connection", brokenBody, /reset/],
300+
]) {
301+
test(`update feed check does not call a pointer stale when GitHub ${name}`, async () => {
302+
const options = updateFeedFixture({ feed: atomFeed([NEWEST]), pointer: pointer() });
303+
await assert.rejects(readNightlyUpdateFeed(options), error);
293304
});
294-
await assert.rejects(readNightlyUpdateFeed(options), /pointer answered HTTP 503/);
295-
});
305+
}

‎.github/workflows/release.yml‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ jobs:
4949
# published nightly, so stable only ever ships a build that nightly users
5050
# have already run. Scheduled runs also decide here whether a nightly is due.
5151
# The PAUSE_NIGHTLY repository variable skips scheduled runs only; every later
52-
# job needs this one, so a skip here skips the whole run.
52+
# job needs this one, so a skip here skips the whole run. `update_feed` runs
53+
# without it and checks the variable itself.
5354
resolve_commit:
5455
name: Resolve release commit
5556
if: github.repository == 'pingdotgg/t3code' && (github.event_name != 'schedule' || vars.PAUSE_NIGHTLY != 'true')
@@ -181,7 +182,6 @@ jobs:
181182
--github-output
182183
183184
echo "release_channel=preview" >> "$GITHUB_OUTPUT"
184-
echo "cli_dist_tag=preview" >> "$GITHUB_OUTPUT"
185185
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
186186
echo "make_latest=false" >> "$GITHUB_OUTPUT"
187187
else
@@ -1048,8 +1048,8 @@ jobs:
10481048

10491049
# A nightly install finds updates in releases.atom, which holds the 10 newest git tags of any
10501050
# kind, so a burst of other tags hides every nightly. The `update-feed` release is the fixed URL
1051-
# newer installs read first. Every scheduled tick and every nightly repairs it, then fails when
1052-
# the feed no longer lists the newest nightly. See docs/operations/release.md#update-feed.
1051+
# newer installs also read. Every scheduled tick and every nightly repairs it, then fails when
1052+
# the feed's first nightly is not the newest one. See docs/operations/release.md#update-feed.
10531053
update_feed:
10541054
name: Check the update feed
10551055
needs: [preflight, release]
@@ -1076,7 +1076,7 @@ jobs:
10761076
core.info(`Newest nightly: ${tag}. Pointer: ${pointerTag}. Feed: ${feedTags?.join(', ')}.`);
10771077
core.setOutput('tag', tag);
10781078
core.setOutput('pointer_stale', pointerTag !== tag);
1079-
core.setOutput('feed_names_it', feedNightly === tag);
1079+
core.setOutput('feed', feedTags === undefined ? 'unreadable' : feedNightly === tag ? 'ok' : 'hidden');
10801080
10811081
- name: Point the update feed at the newest nightly
10821082
if: steps.feed.outputs.pointer_stale == 'true'
@@ -1090,13 +1090,20 @@ jobs:
10901090
gh release create update-feed --prerelease --latest=false --title "Update feed" \
10911091
--notes "The desktop updater reads this release to find the newest nightly. Do not delete it. See docs/operations/release.md."
10921092
gh release upload update-feed nightly.json --clobber
1093+
# A draft's files are not public, so a release someone drafted would hide the pointer.
1094+
gh release edit update-feed --draft=false
10931095
10941096
- name: Fail when the feed hides the newest nightly
1095-
if: steps.feed.outputs.feed_names_it == 'false'
1097+
if: steps.feed.outputs.tag != '' && steps.feed.outputs.feed != 'ok'
10961098
env:
10971099
RELEASE_TAG: ${{ steps.feed.outputs.tag }}
1100+
FEED: ${{ steps.feed.outputs.feed }}
10981101
run: |
1099-
echo "::error::releases.atom could not be read, or its first nightly is not $RELEASE_TAG. Nightly installs older than 0.1.10-nightly.20261112.4603 cannot reach it. A preview from a branch not rebased onto main is the usual cause. See docs/operations/release.md#update-feed."
1102+
if [[ "$FEED" == "unreadable" ]]; then
1103+
echo "::error::releases.atom could not be read, so this run could not check it. No tag cleanup is needed unless a later run reports a hidden nightly."
1104+
else
1105+
echo "::error::The first nightly in releases.atom is not $RELEASE_TAG. Nightly installs older than 0.1.10-nightly.20261112.4603 cannot reach it. A preview from a branch not rebased onto main is the usual cause. See docs/operations/release.md#update-feed."
1106+
fi
11001107
exit 1
11011108
11021109
# The `t3` npm package is a launcher that downloads this version's CLI

‎apps/desktop/src/updates/githubUpdateFeed.test.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const atomFeed = (tags: ReadonlyArray<string>) =>
2828
const offeredRelease = async (
2929
feedTags: ReadonlyArray<string>,
3030
pointerTag: string | undefined,
31-
listedTag?: string,
31+
listedTag?: string | Error,
3232
) => {
3333
let apiScans = 0;
3434
const request = async ({ path = "" }: { readonly path?: string | null }) => {
@@ -40,6 +40,7 @@ const offeredRelease = async (
4040
const manifest = /\/releases\/download\/v([^/]+)\/nightly\.yml$/.exec(path ?? "");
4141
if (manifest) return `version: ${manifest[1]}\npath: T3-Code.exe\nsha512: abc\n`;
4242
apiScans += 1;
43+
if (listedTag instanceof Error) throw listedTag;
4344
return JSON.stringify(listedTag ? [{ tag_name: listedTag, body: "API notes" }] : []);
4445
};
4546
const provider = new GitHubProvider(
@@ -81,6 +82,14 @@ describe("GitHubProvider nightly lookup", () => {
8182
});
8283
});
8384

85+
it("keeps the pointer's answer when the API scan fails", async () => {
86+
const rateLimited = new Error("403");
87+
expect(await offeredRelease(crowdedFeed, nightly(4580), rateLimited)).toMatchObject({
88+
tag: nightly(4580),
89+
apiScans: 1,
90+
});
91+
});
92+
8493
it.each([
8594
["the feed is newer than the pointer", nightly(4603)],
8695
["there is no pointer", undefined],

‎docs/operations/release.md‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ the version.
1919
- push tag matching `v*.*.*` for a stable release of an explicit commit
2020
- scheduled nightly check every 30 minutes
2121
- manual `workflow_dispatch` with `channel=nightly`
22-
- manual `workflow_dispatch` with `channel=preview`, the maintainers' test train. It exercises the whole release flow (build, sign, notarize, smoke, publish) for a commit that end users must never receive, which is how an unmerged branch or a risky change gets a real release run before it lands. It builds the triggering commit with nightly's versioning under the `preview` prerelease identifier (`0.0.41-preview.<date>.<run>`) and leaves its GitHub prerelease as a draft. It publishes nothing to npm. It stays a draft because a draft has no git tag, and published preview tags hide nightlies from the updater (see [Update feed](#update-feed)). Do not publish a preview draft by hand. Preview is not on the schedule, its desktop builds carry no update feed, and no updater manifest (`latest*.yml`, `nightly*.yml`, blockmaps) is attached, so a stable or nightly install cannot be offered one. The only way onto a new preview is downloading the draft by hand as a maintainer: a draft's files are not public, so `T3CODE_CHANNEL=preview` and `t3 update --channel preview` see only previews published before this rule, and `npx t3@preview` no longer works. Rebase a branch onto `main` before dispatching a preview from it. The run uses the branch's own `release.yml`, and an older copy publishes the preview with a tag. The release itself is named as a maintainer test build and its body is a warning rather than generated notes: a changelog of unmerged branch history is not a changelog, and nightly and stable notes are unaffected because each series resolves its previous tag within its own channel. The hosted web app, AUR, and Discord announcements are skipped. Keep it; it costs nothing when idle.
22+
- manual `workflow_dispatch` with `channel=preview`, the maintainers' test train. It exercises the whole release flow (build, sign, notarize, smoke, publish) for a commit that end users must never receive, which is how an unmerged branch or a risky change gets a real release run before it lands. It builds the triggering commit with nightly's versioning under the `preview` prerelease identifier (`0.0.41-preview.<date>.<run>`) and leaves its GitHub prerelease as a draft. It publishes nothing to npm. It stays a draft because a draft has no git tag, and published preview tags hide nightlies from the updater (see [Update feed](#update-feed)). Do not publish a preview draft by hand. Preview is not on the schedule, its desktop builds carry no update feed, and no updater manifest (`latest*.yml`, `nightly*.yml`, blockmaps) is attached, so a stable or nightly install cannot be offered one. The only ways onto a new preview are by hand: the draft release, which maintainers can open, and the run's Actions artifacts. A draft's files are not public, so `T3CODE_CHANNEL=preview` and `t3 update --channel preview` see only previews published before this rule, and `npx t3@preview` fails while npm's `preview` dist-tag names a draft. Rebase a branch onto `main` before dispatching a preview from it. The run uses the branch's own `release.yml`, and an older copy publishes the preview with a tag. The release itself is named as a maintainer test build and its body is a warning rather than generated notes: a changelog of unmerged branch history is not a changelog, and nightly and stable notes are unaffected because each series resolves its previous tag within its own channel. The hosted web app, AUR, and Discord announcements are skipped. Keep it; it costs nothing when idle.
2323
- A manual stable release builds the commit of the latest published nightly, not `main` HEAD.
2424
Nightly is the release candidate: verify the nightly, then promote it. Merges to `main` keep
2525
landing while you verify and never leak into the stable build.
@@ -436,13 +436,13 @@ release archives, and then its npm launcher, available before users can receive
436436

437437
The workflow enforces this ordering:
438438

439-
1. `release` publishes the GitHub Release with the CLI archives and `SHA256SUMS`. Every channel
440-
uploads to a draft and publishes only after all assets are attached, so a new version in the
439+
1. `release` publishes the GitHub Release with the CLI archives and `SHA256SUMS`. Stable and
440+
nightly upload to a draft and publish only after all assets are attached, so a new version in the
441441
desktop update feed already has its archives. **Update everything** relies on this to update
442442
background-service hosts before npm has the version. Rerunning `release` after publication
443443
replaces assets in a public release, so service updates can fail until the upload finishes.
444-
2. `publish_cli` publishes the `t3@<version>` launcher, which downloads from that release, on every
445-
channel.
444+
2. `publish_cli` publishes the `t3@<version>` launcher, which downloads from that release, on
445+
stable and nightly. A preview stays a draft and publishes no launcher.
446446
3. `deploy_web` depends on both before moving the hosted channel to the new client.
447447
`build_web` builds that client earlier with `vercel deploy --prod --skip-domain`, which
448448
leaves the custom domains alone but moves the project's own `*.vercel.app` production
@@ -494,8 +494,10 @@ anything users should not be offered stays a draft or uses one rolling tag, like
494494

495495
To pull a bad nightly, delete its release and tag, then run
496496
`gh release delete-asset update-feed nightly.json`. Installs fall back to the feed until the next
497-
tick rewrites the pointer. Without that command, installs that know the pointer report an update
498-
error until that tick.
497+
unpaused tick or manual nightly rewrites the pointer. Without that command, installs that know the
498+
pointer report an update error until then. If npm's `nightly` dist-tag still names the pulled
499+
build, also move it to the last good one with `npm dist-tag add t3@<version> nightly`. The channel
500+
switch in Settings reads that tag and refuses an older desktop build.
499501

500502
## Desktop auto-update notes
501503

0 commit comments

Comments
 (0)