Files
kuber/build.ts
T

36 lines
914 B
TypeScript

// oxlint-disable no-unused-expressions
import { build } from "bun";
import { createLogger } from "./lib/logger";
import { readdir, rename, rmdir } from "node:fs/promises";
async function platform(p: string) {
const log = createLogger(
p
.split("-")
.map((e) => e[0])
.join(""),
);
log`Build started`;
await build({
compile: true,
minify: true,
target: `bun-${p}` as "bun",
entrypoints: ["index.ts"],
outdir: `dist/${p}`,
features: ["prod"],
bytecode: true,
});
log`Build finished`;
const output = await readdir(`dist/${p}`).then((e) => e[0]!);
const [_, ext] = output.split(".");
await rename(
`dist/${p}/${output}`,
`dist/kuber${p.includes("arm64") ? "-arm64" : ""}${ext ? `.${ext}` : ""}`,
);
await rmdir(`dist/${p}`);
}
const PLATFORMS = ["linux-x64", "linux-arm64", "windows-x64"];
await Promise.all(PLATFORMS.map(platform));