Skip to content

Commit 3c5a5a9

Browse files
t3dotggclaude
andcommitted
fix(desktop): nightly updates no longer depend on GitHub's tag order
The release workflow records the newest nightly at one fixed URL, the `update-feed` release, and the updater reads it before the atom feed. The newer of the two wins. A scheduled job repairs a stale pointer and fails when releases.atom no longer lists the newest nightly, which is the only source older installs read. Co-Authored-By: Claude Fable 5.2 <[email protected]>
1 parent 2f94087 commit 3c5a5a9

7 files changed

Lines changed: 243 additions & 9 deletions

File tree

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,32 @@ async function resolveLatestNightlyCommit({ github, context, core }) {
121121
return { tag, sha: commit.sha, version };
122122
}
123123

124+
// The two places a nightly install looks for an update: releases.atom, which holds the 10 newest
125+
// git tags of any kind, and the `update-feed` pointer. Reports what each names beside the newest
126+
// published nightly, so the caller can repair the pointer and fail when the feed hides the nightly.
127+
async function readNightlyUpdateFeed({ github, context, fetch = globalThis.fetch }) {
128+
const latest = await findLatestNightly({ github, context });
129+
if (!latest) return {};
130+
131+
const base = `https://github.com/${context.repo.owner}/${context.repo.repo}`;
132+
const feed = await fetch(`${base}/releases.atom`);
133+
if (!feed.ok) throw new Error(`releases.atom answered HTTP ${feed.status}.`);
134+
const feedTags = Array.from(
135+
(await feed.text()).matchAll(/href="[^"]*\/releases\/tag\/([^"]+)"/g),
136+
(match) => decodeURIComponent(match[1]),
137+
);
138+
139+
// A missing or unreadable pointer is a stale one; the caller rewrites it.
140+
const pointer = await fetch(`${base}/releases/download/update-feed/nightly.json`);
141+
const pointerTag = pointer.ok ? (await pointer.json().catch(() => ({}))).tag_name : undefined;
142+
143+
return { tag: latest.tagName, feedTags, pointerTag };
144+
}
145+
124146
module.exports = {
125147
assertCommitOnDefaultBranch,
126148
assertReleaseSource,
127149
shouldReleaseNightly,
128150
resolveLatestNightlyCommit,
151+
readNightlyUpdateFeed,
129152
};

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,42 @@ test("stable releases fail when no nightly is published", async () => {
237237
const { options } = nightlyCommitFixture({ releases: [nightly(1, { tagName: "v1.0.0" })] });
238238
await assert.rejects(resolveLatestNightlyCommit(options), /No published nightly found/);
239239
});
240+
241+
const { readNightlyUpdateFeed } = require("./check-nightly-release.cjs");
242+
243+
// GitHub percent-encodes tag names in the feed, and any tag in the repository takes a slot.
244+
const atomEntry = (tag) =>
245+
`<entry><link rel="alternate" type="text/html" href="https://github.com/example/app/releases/tag/${encodeURIComponent(tag)}"/></entry>`;
246+
247+
function updateFeedFixture({ feedTags, pointer }) {
248+
const { options } = fixture({
249+
releases: [nightly(1), nightly(0, { tagName: "v1.0.2-preview.1" })],
250+
});
251+
options.fetch = async (url) =>
252+
url === "https://github.com/example/app/releases.atom"
253+
? new Response(`<feed>${feedTags.map(atomEntry).join("")}</feed>`)
254+
: url === "https://github.com/example/app/releases/download/update-feed/nightly.json"
255+
? pointer
256+
: assert.fail(`unexpected fetch ${url}`);
257+
return options;
258+
}
259+
260+
test("update feed check reports a nightly crowded out of the feed and a missing pointer", async () => {
261+
const feedTags = ["v1.0.2-preview.1", "mobile-android-build/2.3.0/abc"];
262+
assert.deepEqual(
263+
await readNightlyUpdateFeed(
264+
updateFeedFixture({ feedTags, pointer: new Response("Not Found", { status: 404 }) }),
265+
),
266+
{ tag: "v1.0.1-nightly.20260905.123", feedTags, pointerTag: undefined },
267+
);
268+
});
269+
270+
test("update feed check reads the tag the pointer names", async () => {
271+
const feedTags = ["v1.0.1-nightly.20260905.123"];
272+
const pointer = Response.json({ tag_name: "v1.0.1-nightly.20260905.100" });
273+
assert.deepEqual(await readNightlyUpdateFeed(updateFeedFixture({ feedTags, pointer })), {
274+
tag: "v1.0.1-nightly.20260905.123",
275+
feedTags,
276+
pointerTag: "v1.0.1-nightly.20260905.100",
277+
});
278+
});

‎.github/workflows/release.yml‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,59 @@ jobs:
10461046
RELEASE_TAG: ${{ needs.preflight.outputs.tag }}
10471047
run: gh release edit "$RELEASE_TAG" --draft=false
10481048

1049+
# A nightly install finds updates in releases.atom, which holds the 10 newest git tags of any
1050+
# 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.
1053+
update_feed:
1054+
name: Check the update feed
1055+
needs: [preflight, release]
1056+
if: ${{ !cancelled() && github.repository == 'pingdotgg/t3code' && (github.event_name == 'schedule' || needs.preflight.outputs.release_channel == 'nightly') }}
1057+
runs-on: blacksmith-2vcpu-ubuntu-2404
1058+
timeout-minutes: 5
1059+
permissions:
1060+
contents: write
1061+
steps:
1062+
- name: Checkout
1063+
uses: actions/checkout@v6
1064+
with:
1065+
sparse-checkout: .github/scripts
1066+
1067+
- id: feed
1068+
name: Read the update feed
1069+
uses: actions/github-script@v8
1070+
with:
1071+
retries: 3
1072+
script: |
1073+
const { readNightlyUpdateFeed } = require('./.github/scripts/check-nightly-release.cjs');
1074+
const { tag, feedTags, pointerTag } = await readNightlyUpdateFeed({ github, context });
1075+
if (!tag) return;
1076+
core.info(`Newest nightly: ${tag}. Pointer: ${pointerTag}. Feed: ${feedTags.join(', ')}.`);
1077+
core.setOutput('tag', tag);
1078+
core.setOutput('pointer_stale', pointerTag !== tag);
1079+
core.setOutput('in_feed', feedTags.includes(tag));
1080+
1081+
- name: Point the update feed at the newest nightly
1082+
if: steps.feed.outputs.pointer_stale == 'true'
1083+
env:
1084+
GH_TOKEN: ${{ github.token }}
1085+
GH_REPO: ${{ github.repository }}
1086+
RELEASE_TAG: ${{ steps.feed.outputs.tag }}
1087+
run: |
1088+
gh api "repos/$GH_REPO/releases/tags/$RELEASE_TAG" --jq '{tag_name, name, body}' > nightly.json
1089+
gh release view update-feed > /dev/null 2>&1 ||
1090+
gh release create update-feed --prerelease --latest=false --title "Update feed" \
1091+
--notes "The desktop updater reads this release to find the newest nightly. Do not delete it. See docs/operations/release.md."
1092+
gh release upload update-feed nightly.json --clobber
1093+
1094+
- name: Fail when the feed hides the newest nightly
1095+
if: steps.feed.outputs.in_feed == 'false'
1096+
env:
1097+
RELEASE_TAG: ${{ steps.feed.outputs.tag }}
1098+
run: |
1099+
echo "::error::releases.atom does not list $RELEASE_TAG. Nightly installs older than 0.1.10-nightly.20261112.4603 cannot update. See docs/operations/release.md#update-feed."
1100+
exit 1
1101+
10491102
# The `t3` npm package is a launcher that downloads this version's CLI
10501103
# archive from the GitHub Release, so it publishes only once that release
10511104
# exists. Preview publishes too, under the `preview` dist-tag, which
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import * as NodeModule from "node:module";
2+
3+
import { GitHubProvider } from "electron-updater/out/providers/GitHubProvider.js";
4+
import { describe, expect, it } from "vite-plus/test";
5+
6+
type ProviderArgs = ConstructorParameters<typeof GitHubProvider>;
7+
8+
// electron-updater's own dependency, which apps/desktop does not declare.
9+
const semver = NodeModule.createRequire(
10+
NodeModule.createRequire(import.meta.url).resolve("electron-updater"),
11+
)("semver") as { parse: (version: string) => ProviderArgs[1]["currentVersion"] };
12+
13+
const REPO = "/pingdotgg/t3code";
14+
const nightly = (build: number) => `v0.1.10-nightly.20261112.${build}`;
15+
16+
const atomFeed = (tags: ReadonlyArray<string>) =>
17+
`<feed xmlns="http://www.w3.org/2005/Atom">${tags
18+
.map(
19+
(tag) =>
20+
`<entry><link rel="alternate" type="text/html" href="https://github.com${REPO}/releases/tag/${tag}"/><title>${tag}</title><content type="html">${tag} feed notes</content></entry>`,
21+
)
22+
.join("")}</feed>`;
23+
24+
/** The tag a nightly install is offered when GitHub serves this feed and this `update-feed` pointer. */
25+
const offeredRelease = async (feedTags: ReadonlyArray<string>, pointerTag: string | undefined) => {
26+
const request = async ({ path = "" }: { readonly path?: string | null }) => {
27+
if (path === `${REPO}/releases.atom`) return atomFeed(feedTags);
28+
if (path === `${REPO}/releases/download/update-feed/nightly.json`) {
29+
if (pointerTag === undefined) throw new Error("404");
30+
return JSON.stringify({ tag_name: pointerTag, name: pointerTag, body: "pointer notes" });
31+
}
32+
const manifest = /\/releases\/download\/v([^/]+)\/nightly\.yml$/.exec(path ?? "");
33+
if (manifest) return `version: ${manifest[1]}\npath: T3-Code.exe\nsha512: abc\n`;
34+
// The API scan, the last resort, finds nothing.
35+
return "[]";
36+
};
37+
const provider = new GitHubProvider(
38+
{ provider: "github", owner: "pingdotgg", repo: "t3code" },
39+
// Only the four fields the provider reads; a real AppUpdater needs Electron.
40+
{
41+
allowPrerelease: true,
42+
channel: "nightly",
43+
currentVersion: semver.parse("0.1.10-nightly.20261112.4580"),
44+
fullChangelog: false,
45+
} as ProviderArgs[1],
46+
{
47+
isUseMultipleRangeRequest: false,
48+
platform: "win32",
49+
executor: { request },
50+
} as ProviderArgs[2],
51+
);
52+
const { tag, releaseNotes } = await provider.getLatestVersion();
53+
return { tag, releaseNotes };
54+
};
55+
56+
// What filled releases.atom on 2026-11-12: ten tags, none of them a nightly.
57+
const crowdedFeed = Array.from({ length: 10 }, (_, i) => `v0.1.10-preview.20261112.${4550 + i}`);
58+
59+
describe("GitHubProvider nightly lookup", () => {
60+
it("finds the newest nightly at the fixed pointer when other tags fill the feed", async () => {
61+
expect(await offeredRelease(crowdedFeed, nightly(4606))).toEqual({
62+
tag: nightly(4606),
63+
releaseNotes: "pointer notes",
64+
});
65+
});
66+
67+
it.each([
68+
["the feed is newer than the pointer", [nightly(4606)], nightly(4603)],
69+
["there is no pointer", [nightly(4606)], undefined],
70+
["the pointer names another channel", [nightly(4606)], "v0.1.10-preview.20261112.4700"],
71+
])("keeps the feed's nightly when %s", async (_case, feedTags, pointerTag) => {
72+
expect(await offeredRelease(feedTags, pointerTag)).toEqual({
73+
tag: nightly(4606),
74+
releaseNotes: `${nightly(4606)} feed notes`,
75+
});
76+
});
77+
});

‎docs/operations/release.md‎

Lines changed: 21 additions & 1 deletion
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, plus the npm packages under the `preview` dist-tag. It stays a draft because a draft has no git tag. `releases.atom` lists the 10 newest tags in the repository, same-day `preview` tags sort above `nightly` ones, and nightly updaters older than 0.1.10-nightly.20261112.4603 find updates only in that feed, so ten published previews hide every nightly from them. Do not publish a preview draft by hand; converting it back to a draft afterwards leaves the tag in the feed until the tag is deleted. Preview is not on the schedule, no default npm dist-tag points at it, 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 it is downloading the draft by hand as a maintainer; `npx t3@preview`, `T3CODE_CHANNEL=preview`, and `t3 update --channel preview` cannot reach a draft's assets. Each of those paths prints a warning, and the CLI asks for confirmation when the running build is not itself a preview. 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, plus the npm packages under the `preview` dist-tag. 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, no default npm dist-tag points at it, 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 it is downloading the draft by hand as a maintainer; `npx t3@preview`, `T3CODE_CHANNEL=preview`, and `t3 update --channel preview` cannot reach a draft's assets. Each of those paths prints a warning, and the CLI asks for confirmation when the running build is not itself a preview. 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.
@@ -465,6 +465,26 @@ verify that the update stops before restart and run `npx t3@<version> service up
465465
server machine. Also test the manual or desktop-managed guidance when those environments are
466466
available.
467467

468+
## Update feed
469+
470+
A nightly install finds the newest nightly in two places.
471+
472+
- `releases.atom` lists the 10 newest git tags in the repository, of any kind, and same-day
473+
`preview` tags sort above `nightly` ones. Installs built before the pointer existed read nothing
474+
else: nightlies before `0.1.10-nightly.20261112.4603`, and stable `0.1.9` and older switched to
475+
the nightly channel. Ten other tags in a row hide every nightly from them.
476+
- `releases/download/update-feed/nightly.json` names the newest nightly. Newer installs read it
477+
first and take the newer of it and the feed, so their updates do not depend on tag order. The
478+
`update-feed` release holds that file. Never delete it.
479+
480+
The release workflow's `Check the update feed` job runs on every scheduled tick and after every
481+
nightly. It rewrites a stale pointer, then fails when the feed does not list the newest nightly.
482+
483+
When it fails, old installs cannot update. The job log lists the tags that fill the feed. Delete
484+
the ones nothing needs with `git push origin :refs/tags/<tag>`. Converting a release to a draft
485+
keeps its tag, so it does not help. To keep this from happening, anything users should not be
486+
offered stays a draft or uses one rolling tag, like `desktop-preview`.
487+
468488
## Desktop auto-update notes
469489

470490
- Updater runtime: `apps/desktop/src/updates/DesktopUpdates.ts`.

‎patches/[email protected]‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,32 @@ index 0ae9e1126e1dc136977914ef1bfd46709fc9db1b..c298ffe7808c421c29e16f1e2ba8510f
3939
request.on("redirect", (statusCode, method, redirectUrl) => {
4040
// no way to modify request options, abort old and make a new one
4141
diff --git a/out/providers/GitHubProvider.js b/out/providers/GitHubProvider.js
42-
index e768d24e7a957caf32a4b8ca6c68cb50eb5865ee..34a0759220c0cce052285204b2d14fdf0db905e5 100644
42+
index e768d24e7a957caf32a4b8ca6c68cb50eb5865ee..8ffb1a1047bae2329f071fc2ab5db4e90db8b9a6 100644
4343
--- a/out/providers/GitHubProvider.js
4444
+++ b/out/providers/GitHubProvider.js
45-
@@ -107,6 +107,12 @@ class GitHubProvider extends BaseGitHubProvider {
45+
@@ -107,6 +107,21 @@ class GitHubProvider extends BaseGitHubProvider {
4646
catch (e) {
4747
throw (0, builder_util_runtime_1.newError)(`Cannot parse releases feed: ${e.stack || e.message},\nXML:\n${feedXml}`, "ERR_UPDATER_INVALID_RELEASE_FEED");
4848
}
49-
+ // The atom feed lists only the 10 newest releases, which other prereleases can fill.
49+
+ // The atom feed lists only the 10 newest git tags of any kind, in an order GitHub picks, so
50+
+ // the release workflow also records a prerelease channel's newest release at one fixed URL.
51+
+ // The newer of the two answers wins; the API scan is the last resort.
5052
+ let apiRelease = null;
53+
+ if (this.updater.allowPrerelease && this.updater.channel) {
54+
+ const pointer = await this.getChannelPointerRelease(this.updater.channel, cancellationToken);
55+
+ if (pointer !== null && (tag == null || semver.gt(pointer.tag_name, tag))) {
56+
+ apiRelease = pointer;
57+
+ tag = pointer.tag_name;
58+
+ }
59+
+ }
5160
+ if (tag == null && this.updater.allowPrerelease && this.updater.channel) {
5261
+ apiRelease = await this.getLatestChannelRelease(this.updater.channel, cancellationToken);
5362
+ tag = apiRelease === null ? null : apiRelease.tag_name;
5463
+ }
5564
if (tag == null) {
5665
throw (0, builder_util_runtime_1.newError)(`No published versions on GitHub`, "ERR_UPDATER_NO_PUBLISHED_VERSIONS");
5766
}
58-
@@ -144,6 +150,14 @@ class GitHubProvider extends BaseGitHubProvider {
67+
@@ -144,6 +159,14 @@ class GitHubProvider extends BaseGitHubProvider {
5968
}
6069
}
6170
const result = (0, Provider_1.parseUpdateInfo)(rawData, channelFile, channelFileUrl);
@@ -70,10 +79,23 @@ index e768d24e7a957caf32a4b8ca6c68cb50eb5865ee..34a0759220c0cce052285204b2d14fdf
7079
if (result.releaseName == null) {
7180
result.releaseName = latestRelease.elementValueOrEmpty("title");
7281
}
73-
@@ -155,6 +169,29 @@ class GitHubProvider extends BaseGitHubProvider {
82+
@@ -155,6 +178,42 @@ class GitHubProvider extends BaseGitHubProvider {
7483
...result,
7584
};
7685
}
86+
+ async getChannelPointerRelease(channel, cancellationToken) {
87+
+ try {
88+
+ const url = (0, util_1.newUrlFromBase)(this.getBaseDownloadPath("update-feed", `${channel}.json`), this.baseUrl);
89+
+ const rawData = await this.httpRequest(url, { accept: "application/json, */*" }, cancellationToken);
90+
+ const release = rawData == null ? null : JSON.parse(rawData);
91+
+ const releaseChannel = release == null || typeof release.tag_name !== "string" ? null : semver.prerelease(release.tag_name);
92+
+ return releaseChannel !== null && releaseChannel[0] === channel ? release : null;
93+
+ }
94+
+ catch (e) {
95+
+ // A fork, or a moment between two uploads, has no pointer. The feed still answers.
96+
+ return null;
97+
+ }
98+
+ }
7799
+ async getLatestChannelRelease(channel, cancellationToken) {
78100
+ for (let page = 1; page <= 5; page++) {
79101
+ const url = new url_1.URL(`${this.computeGithubBasePath(`/repos/${this.options.owner}/${this.options.repo}/releases`)}?per_page=100&page=${page}`, this.baseApiUrl);

0 commit comments

Comments
 (0)