Skip to content
TypeScript

feat(release): ship a Linux .deb that updates itself (#13575)

Theo Brownec13f7d93fff0
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index c374a8692db..c743b961560 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -510,6 +510,7 @@ jobs:
"release/*.dmg"
"release/*.zip"
"release/*.AppImage"
+ "release/*.deb"
"release/*.exe"
)
# Preview builds have no publish config, so electron-builder writes
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 387330713d0..014176b8761 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -625,7 +625,7 @@ jobs:
clerk_cli_oauth_client_id: ${{ needs.relay_public_config.outputs.clerk_cli_oauth_client_id }}
relay_url: ${{ needs.relay_public_config.outputs.relay_url }}
label: Linux arm64
- runner: ubuntu-24.04-arm
+ runner: blacksmith-16vcpu-ubuntu-2404-arm
platform: linux
target: AppImage
arch: arm64
@@ -875,6 +875,7 @@ jobs:
echo 'release-assets/*.dmg'
echo 'release-assets/*.zip'
echo 'release-assets/*.AppImage'
+ echo 'release-assets/*.deb'
echo 'release-assets/*.exe'
if [[ "${{ needs.preflight.outputs.release_channel }}" != "preview" ]]; then
echo 'release-assets/*.blockmap'
diff --git a/README.md b/README.md
index 28cc7816208..175e52d9de4 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,14 @@ winget install T3Tools.T3Code
brew install --cask t3-code
```
+#### Debian, Ubuntu (`.deb`)
+
+Download the `.deb` from [GitHub Releases](https://github.com/pingdotgg/t3code/releases), then:
+
+```bash
+sudo apt install ./T3-Code-*.deb
+```
+
#### Arch Linux (AUR)
Stable:
diff --git a/apps/desktop/src/updates/DesktopUpdates.test.ts b/apps/desktop/src/updates/DesktopUpdates.test.ts
index c9ed4c66bce..9745662c120 100644
--- a/apps/desktop/src/updates/DesktopUpdates.test.ts
+++ b/apps/desktop/src/updates/DesktopUpdates.test.ts
@@ -87,6 +87,25 @@ describe("DesktopUpdates", () => {
}).pipe(Effect.provide(Layer.merge(TestClock.layer(), harness.layer)));
});
+ it.effect("updates Linux .deb installs and leaves other non-AppImage installs off", () =>
+ Effect.gen(function* () {
+ const linuxState = (packageType: string | undefined) =>
+ Effect.scoped(
+ Effect.gen(function* () {
+ const updates = yield* DesktopUpdates.DesktopUpdates;
+ yield* updates.configure;
+ return yield* updates.getState;
+ }),
+ ).pipe(Effect.provide(makeHarness({ platform: "linux", packageType }).layer));
+
+ const deb = yield* linuxState("deb\n");
+ assert.equal(deb.status, "idle");
+
+ const unmarked = yield* linuxState(undefined);
+ assert.equal(unmarked.status, "disabled");
+ }),
+ );
+
it.effect("subscribe delivers the latest state plus subsequent changes", () => {
const harness = makeHarness();
diff --git a/apps/desktop/src/updates/DesktopUpdates.ts b/apps/desktop/src/updates/DesktopUpdates.ts
index c42ef564918..245925a6e73 100644
--- a/apps/desktop/src/updates/DesktopUpdates.ts
+++ b/apps/desktop/src/updates/DesktopUpdates.ts
@@ -250,6 +250,7 @@ function getAutoUpdateDisabledReason(args: {
isPackaged: boolean;
platform: NodeJS.Platform;
appImage?: string | undefined;
+ isDebPackage: boolean;
disabledByEnv: boolean;
hasUpdateFeedConfig: boolean;
}): string | null {
@@ -262,8 +263,8 @@ function getAutoUpdateDisabledReason(args: {
if (args.disabledByEnv) {
return "Automatic updates are disabled by the T3CODE_DISABLE_AUTO_UPDATE setting.";
}
- if (args.platform === "linux" && !args.appImage) {
- return "Automatic updates on Linux require running the AppImage build.";
+ if (args.platform === "linux" && !args.appImage && !args.isDebPackage) {
+ return "Automatic updates on Linux require the AppImage or the .deb package.";
}
return null;
}
@@ -332,6 +333,18 @@ export const make = Effect.gen(function* () {
),
);
+ // The .deb carries electron-builder's resources/package-type marker.
+ // electron-updater reads the same file and installs updates with dpkg.
+ const isDebPackage =
+ environment.platform === "linux" && environment.isPackaged
+ ? yield* fileSystem
+ .readFileString(environment.path.join(environment.resourcesPath, "package-type"))
+ .pipe(
+ Effect.map((packageType) => packageType.trim() === "deb"),
+ Effect.orElseSucceed(() => false),
+ )
+ : false;
+
const hasUpdateFeedConfig = Ref.get(appUpdateYmlConfigRef).pipe(
Effect.map((appUpdateYmlConfig) => Option.isSome(appUpdateYmlConfig) || config.mockUpdates),
);
@@ -344,6 +357,7 @@ export const make = Effect.gen(function* () {
isPackaged: environment.isPackaged,
platform: environment.platform,
appImage: Option.getOrUndefined(config.appImagePath),
+ isDebPackage,
disabledByEnv: config.disableAutoUpdate,
hasUpdateFeedConfig: hasFeedConfig,
}),
diff --git a/apps/desktop/src/updates/updatesTestHarness.ts b/apps/desktop/src/updates/updatesTestHarness.ts
index a0b9a36399d..5455f160285 100644
--- a/apps/desktop/src/updates/updatesTestHarness.ts
+++ b/apps/desktop/src/updates/updatesTestHarness.ts
@@ -2,6 +2,7 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
import type { DesktopUpdateState } from "@t3tools/contracts";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
+import * as PlatformError from "effect/PlatformError";
import * as Layer from "effect/Layer";
import * as Option from "effect/Option";
@@ -33,6 +34,9 @@ export interface UpdatesHarnessOptions {
readonly stopBackend?: Effect.Effect<void>;
readonly startBackend?: Effect.Effect<void>;
readonly env?: Record<string, string | undefined>;
+ readonly platform?: NodeJS.Platform;
+ /** Contents of the resources/package-type marker a Linux package ships. */
+ readonly packageType?: string | undefined;
}
export function makeHarness(options: UpdatesHarnessOptions = {}) {
@@ -146,7 +150,7 @@ export function makeHarness(options: UpdatesHarnessOptions = {}) {
const environmentLayer = DesktopEnvironment.layer({
dirname: "/repo/apps/desktop/src",
homeDirectory: `/tmp/t3-desktop-updates-home-${process.pid}`,
- platform: "darwin",
+ platform: options.platform ?? "darwin",
processArch: "x64",
appVersion: "1.2.3",
appPath: "/repo",
@@ -208,6 +212,17 @@ export function makeHarness(options: UpdatesHarnessOptions = {}) {
// disk I/O that would outrun the tests' settle loops.
const updateRestartMarkers = new Set<string>();
const fileSystemLayer = FileSystem.layerNoop({
+ readFileString: (path) =>
+ path === "/missing/resources/package-type" && options.packageType !== undefined
+ ? Effect.succeed(options.packageType)
+ : Effect.fail(
+ PlatformError.systemError({
+ module: "FileSystem",
+ method: "readFileString",
+ _tag: "NotFound",
+ pathOrDescriptor: path,
+ }),
+ ),
makeDirectory: () => Effect.void,
writeFileString: (path) =>
Effect.sync(() => {
diff --git a/apps/marketing/src/pages/download.astro b/apps/marketing/src/pages/download.astro
index f3212d1e38a..7fb22e52f48 100644
--- a/apps/marketing/src/pages/download.astro
+++ b/apps/marketing/src/pages/download.astro
@@ -91,6 +91,16 @@ const imageProps = {
<h2 class="platform-name">Linux</h2>
</div>
<div class="download-cards">
+ <a class="download-card" data-asset="amd64.deb" href={RELEASES_URL}>
+ <span class="card-icon">
+ <Image class="card-icon--stable" src={iconStable} width={28} height={28} loading="lazy" {...imageProps} />
+ <Image class="card-icon--nightly" src={iconNightly} width={28} height={28} loading="lazy" {...imageProps} />
+ </span>
+ <span class="card-text">
+ <span class="card-arch">Debian, Ubuntu</span>
+ <span class="card-format">.deb</span>
+ </span>
+ </a>
<a class="download-card" data-asset="x86_64.AppImage" href={RELEASES_URL}>
<span class="card-icon">
<Image class="card-icon--stable" src={iconStable} width={28} height={28} loading="lazy" {...imageProps} />
@@ -102,6 +112,10 @@ const imageProps = {
</span>
</a>
</div>
+ <p class="intel-note">
+ On ARM? Download the arm64 <a data-asset="arm64.deb" href={RELEASES_URL}>.deb</a> or
+ <a data-asset="arm64.AppImage" href={RELEASES_URL}>AppImage</a>.
+ </p>
</section>
<!-- Mobile. Stable only, there is no nightly mobile build. -->
diff --git a/docs/operations/release.md b/docs/operations/release.md
index a86a36432d3..4116ceeb388 100644
--- a/docs/operations/release.md
+++ b/docs/operations/release.md
@@ -29,7 +29,7 @@ This document covers the unified release workflow for stable and nightly desktop
- Builds six desktop artifacts in parallel for both channels, each as its own job (`desktop_<platform>_<arch>`, one call of `release-desktop.yml`) on hardware of its own architecture, gated only on the bundle (the Windows jobs also wait for the same-arch Linux job, whose CLI archive they embed as the WSL runtime):
- macOS `arm64` DMG
- macOS `x64` DMG
- - Linux `x64` and `arm64` AppImage
+ - Linux `x64` and `arm64` AppImage and `.deb`, from one electron-builder run. The `.deb` updates in the app through electron-updater, which installs it with `dpkg`.
- Windows `x64` and `arm64` NSIS installer
- Publishes one GitHub Release with all produced files.
- Stable tags with a suffix after `X.Y.Z` (for example `1.2.3-alpha.1`) are published as GitHub prereleases.
@@ -329,7 +329,7 @@ available.
- `T3CODE_DESKTOP_UPDATE_REPOSITORY` (format `owner/repo`), if set.
- otherwise `GITHUB_REPOSITORY` from GitHub Actions.
- Required release assets for updater:
- - platform installers (`.exe`, `.dmg`, `.AppImage`, plus macOS `.zip` for Squirrel.Mac update payloads)
+ - platform installers (`.exe`, `.dmg`, `.AppImage`, `.deb`, plus macOS `.zip` for Squirrel.Mac update payloads)
- channel metadata: `latest*.yml` for stable releases, `nightly*.yml` for nightly releases
- `*.blockmap` files (used for differential downloads)
- macOS metadata note:
diff --git a/docs/user/install.md b/docs/user/install.md
index 773979e7730..53ad5fbbed8 100644
--- a/docs/user/install.md
+++ b/docs/user/install.md
@@ -58,12 +58,17 @@ update it with `git pull` and a rebuild.
Download a release from [GitHub Releases](https://github.com/pingdotgg/t3code/releases),
or use a package manager:
-| Platform | Install |
-| ------------------ | ------------------------------- |
-| Windows | `winget install T3Tools.T3Code` |
-| macOS | `brew install --cask t3-code` |
-| Arch Linux | `yay -S t3code-bin` |
-| Arch Linux nightly | `yay -S t3code-nightly-bin` |
+| Platform | Install |
+| ------------------ | ---------------------------------- |
+| Windows | `winget install T3Tools.T3Code` |
+| macOS | `brew install --cask t3-code` |
+| Debian, Ubuntu | `sudo apt install ./T3-Code-*.deb` |
+| Arch Linux | `yay -S t3code-bin` |
+| Arch Linux nightly | `yay -S t3code-nightly-bin` |
+
+The `.deb` updates itself like the other desktop builds. It asks for your
+password to install each update. If your desktop has no password prompt, the
+update fails. Download the new `.deb` and install it the same way.
### Windows Subsystem for Linux
diff --git a/scripts/build-desktop-artifact.test.ts b/scripts/build-desktop-artifact.test.ts
index 05fc0baa45a..4e97301ddba 100644
--- a/scripts/build-desktop-artifact.test.ts
+++ b/scripts/build-desktop-artifact.test.ts
@@ -668,6 +668,8 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
iconSize: 120,
iconTextSize: 12,
});
+ // A Linux AppImage build also emits the .deb from the same run.
+ assert.deepStrictEqual((linux.linux as Record<string, unknown>).target, ["AppImage", "deb"]);
// Linux must register the renderer schemes so the generated .desktop
// entry advertises MimeType=x-scheme-handler/t3code; for OAuth deep links.
assert.deepStrictEqual((linux.linux as Record<string, unknown>).protocols, [
diff --git a/scripts/build-desktop-artifact.ts b/scripts/build-desktop-artifact.ts
index 02e514d83fb..c05716ced8f 100644
--- a/scripts/build-desktop-artifact.ts
+++ b/scripts/build-desktop-artifact.ts
@@ -929,6 +929,7 @@ interface StagePackageJson {
readonly private: true;
readonly packageManager: string;
readonly description: string;
+ readonly homepage: string;
readonly author: string;
readonly main: string;
readonly build: Record<string, unknown>;
@@ -2733,10 +2734,17 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
if (platform === "linux") {
buildConfig.linux = {
- target: [target],
+ // The .deb is built from the same unpacked app after the AppImage.
+ // electron-builder lists both in latest-linux.yml and writes
+ // resources/package-type into the .deb only, so electron-updater updates
+ // each install in its own format.
+ target: target === "AppImage" ? [target, "deb"] : [target],
executableName: "t3code",
icon: "icons",
category: "Development",
+ synopsis: "Desktop GUI for coding agents",
+ // Required by the .deb control file.
+ maintainer: "T3 Tools <[email protected]>",
// electron-builder turns these into MimeType=x-scheme-handler/<scheme>;
// in the .desktop entry (Exec already gets %U), so browsers can hand
// t3code:// OAuth callbacks to the app.
@@ -2752,6 +2760,23 @@ export const createBuildConfig = Effect.fn("createBuildConfig")(function* (
},
},
};
+ buildConfig.deb = {
+ // Electron's runtime libraries. Debian 13 and Ubuntu 24.04 renamed some
+ // for 64-bit time; the old name is the fallback for older releases.
+ depends: [
+ "libasound2t64 | libasound2",
+ "libatspi2.0-0t64 | libatspi2.0-0",
+ "libgbm1",
+ "libgtk-3-0t64 | libgtk-3-0",
+ "libnotify4",
+ "libnss3",
+ "libsecret-1-0",
+ "libuuid1",
+ "libxss1",
+ "libxtst6",
+ "xdg-utils",
+ ],
+ };
}
if (platform === "win") {
@@ -3642,6 +3667,8 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
private: true,
packageManager: rootPackageJson.packageManager,
description: "T3 Code desktop build",
+ // Required by the .deb control file.
+ homepage: "https://t3.codes",
author: "T3 Tools",
main: "apps/desktop/dist-electron/main.cjs",
build: yield* createBuildConfig(
@@ -3738,6 +3765,11 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
delete buildEnv[key];
}
}
+ if (options.platform === "linux") {
+ // fpm compresses the .deb with the system xz through tar. Threaded mode
+ // takes seconds on a many-core runner instead of about two minutes.
+ buildEnv.XZ_DEFAULTS = "-T0";
+ }
if (!options.signed) {
buildEnv.CSC_IDENTITY_AUTO_DISCOVERY = "false";
delete buildEnv.CSC_LINK;