Skip to content

Commit 7c9513c

Browse files
noreplyclaude
andcommitted
fork: a GitHub Actions build names the repository it runs in
Without T3CODE_RELEASE_REPOSITORY, an Actions build takes GITHUB_REPOSITORY, as the desktop updater feed already does. Reusable workflows (release-desktop.yml re-bundles the server for the CLI executable) do not pass the caller's env on, so the explicit variable alone would let a fork's CLI archive name upstream. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d874ab2 commit 7c9513c

2 files changed

Lines changed: 20 additions & 7 deletions

File tree

‎scripts/lib/release-repository.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ describe("release repository build setting", () => {
1717
});
1818
});
1919

20+
it("names the repository a GitHub Actions build runs in, unless the setting overrides it", () => {
21+
const actions = { GITHUB_ACTIONS: "true", GITHUB_REPOSITORY: "fork-owner/t3code" };
22+
expect(resolveReleaseRepository(actions)).toBe("fork-owner/t3code");
23+
expect(
24+
resolveReleaseRepository({ ...actions, T3CODE_RELEASE_REPOSITORY: "other/t3code" }),
25+
).toBe("other/t3code");
26+
// Outside Actions a stray GITHUB_REPOSITORY changes nothing.
27+
expect(resolveReleaseRepository({ GITHUB_REPOSITORY: "fork-owner/t3code" })).toBe("");
28+
});
29+
2030
it("fails the build on a malformed value instead of falling back to upstream", () => {
2131
for (const value of ["owner", "owner/repo/extra", "owner/..", "https://github.com/o/r"]) {
2232
expect(() => resolveReleaseRepository({ T3CODE_RELEASE_REPOSITORY: value })).toThrow(

‎scripts/lib/release-repository.ts‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/**
2-
* The GitHub repository whose releases a build updates from, baked in at build time.
3-
*
4-
* Empty means the upstream default in `@t3tools/shared/cliRelease`. A fork's release workflow sets
5-
* `T3CODE_RELEASE_REPOSITORY=<owner>/<repo>` so its builds look only at the fork's releases: the
6-
* Update button and `t3 update` can then never install an upstream build over the fork.
2+
* The repository a build updates from: T3CODE_RELEASE_REPOSITORY, else an Actions build's own
3+
* GITHUB_REPOSITORY (reusable workflows drop the caller's env), else "" for upstream. Keeps a
4+
* fork's Update button and `t3 update` on the fork's releases.
75
*/
86
export const RELEASE_REPOSITORY_ENV = "T3CODE_RELEASE_REPOSITORY";
97

@@ -18,11 +16,16 @@ function isValidSegment(value: string | undefined): value is string {
1816
export function resolveReleaseRepository(
1917
env: Readonly<Record<string, string | undefined>> = process.env,
2018
): string {
21-
const configured = env[RELEASE_REPOSITORY_ENV]?.trim() ?? "";
19+
const configured =
20+
env[RELEASE_REPOSITORY_ENV]?.trim() ||
21+
(env.GITHUB_ACTIONS === "true" ? env.GITHUB_REPOSITORY?.trim() : "") ||
22+
"";
2223
if (configured === "") return "";
2324
const [owner, name, ...rest] = configured.split("/");
2425
if (!isValidSegment(owner) || !isValidSegment(name) || rest.length > 0) {
25-
throw new Error(`${RELEASE_REPOSITORY_ENV} must be "<owner>/<repo>", got "${configured}".`);
26+
throw new Error(
27+
`${RELEASE_REPOSITORY_ENV} (or GITHUB_REPOSITORY) must be "<owner>/<repo>", got "${configured}".`,
28+
);
2629
}
2730
return configured;
2831
}

0 commit comments

Comments
 (0)