Release standalone binaries with a one-line installer
Installing meant Bun, a clone with the T3 Code submodule and a build. Now a tag builds a binary per platform with bun build --compile, carrying Bun's runtime and OpenTUI's native library, and publishes them as a GitHub Release after opening each one's dashboard on its own OS. install.sh picks the right binary and checks it against SHA256SUMS; `t3tui upgrade` replaces an installed binary with the latest release and `t3tui version` prints the version. `t3tui tmux` started its windows as `bun <file>`, which a compiled binary can't do, so it now runs itself.
This commit is contained in:
1 parent
c0b7615590
commit
9bf9abb540
10 files changed
+319
-2
No files matched your search
@@ -0,0 +1,32 @@
|
||||
// Compiles t3tui into one executable per platform, with Bun's runtime and OpenTUI's native
|
||||
// library inside, so users need neither Bun nor a checkout. Usage:
|
||||
// bun run compile [linux-x64 linux-arm64 darwin-x64 darwin-arm64]
|
||||
// With no targets it builds for this machine. Binaries land in release/t3tui-<os>-<arch>.
|
||||
// Cross-compiling needs every platform's OpenTUI package: bun install --os='*' --cpu='*'
|
||||
import { $ } from "bun";
|
||||
import { existsSync } from "node:fs";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
const TARGETS = ["linux-x64", "linux-arm64", "darwin-x64", "darwin-arm64"];
|
||||
// Every native package OpenTUI might import. Each binary keeps only its own platform's.
|
||||
const NATIVE = [...TARGETS, "linux-x64-musl", "linux-arm64-musl", "win32-x64", "win32-arm64"].map((t) => `@opentui/core-${t}`);
|
||||
|
||||
const root = join(import.meta.dir, "..");
|
||||
const outdir = join(root, "release");
|
||||
const targets = process.argv.slice(2);
|
||||
if (targets.length === 0) targets.push(`${process.platform}-${process.arch}`);
|
||||
for (const target of targets) {
|
||||
if (!TARGETS.includes(target)) throw new Error(`unknown target ${target}; expected one of ${TARGETS.join(", ")}`);
|
||||
if (!existsSync(join(root, "node_modules/@opentui", `core-${target}`))) {
|
||||
throw new Error(`@opentui/core-${target} isn't installed; run bun install --os='*' --cpu='*'`);
|
||||
}
|
||||
}
|
||||
|
||||
await mkdir(outdir, { recursive: true });
|
||||
for (const target of targets) {
|
||||
const outfile = join(outdir, `t3tui-${target}`);
|
||||
const external = NATIVE.filter((name) => name !== `@opentui/core-${target}`).flatMap((name) => ["--external", name]);
|
||||
// OpenTUI starts its syntax highlighter from parser.worker.js, so it's compiled in as a second entrypoint.
|
||||
await $`bun build --compile --minify --target=bun-${target} ${external} ${join(root, "src/bin.ts")} ${join(root, "node_modules/@opentui/core/parser.worker.js")} --outfile ${outfile}`.cwd(root);
|
||||
}
|
||||
Reference in new issue
Block a user