This commit is contained in:
Dax Raad
2025-05-30 21:26:53 -04:00
parent f3da73553c
commit f50a57041f
4 changed files with 41 additions and 21 deletions

View File

@@ -4,19 +4,15 @@ import { $ } from "bun"
import pkg from "../package.json"
const dry = process.argv.includes("--dry")
const version = `0.0.0-${Date.now()}`
const ARCH = {
const GOARCH: Record<string, string> = {
arm64: "arm64",
x64: "amd64",
}
const OS = {
linux: "linux",
darwin: "mac",
win32: "windows",
}
const targets = [
["linux", "arm64"],
["linux", "x64"],
@@ -32,20 +28,24 @@ for (const [os, arch] of targets) {
console.log(`building ${os}-${arch}`)
const name = `${pkg.name}-${os}-${arch}`
await $`mkdir -p dist/${name}/bin`
await $`bun build --compile --minify --target=bun-${os}-${arch} --outfile=dist/${name}/bin/${pkg.name} ./src/index.ts`
await $`GOOS=${os} GOARCH=${GOARCH[arch]} go build -o ../opencode/dist/${name}/bin/tui ../tui/main.go`.cwd(
"../tui",
)
await $`bun build --compile --minify --target=bun-${os}-${arch} --outfile=dist/${name}/bin/opencode ./src/index.ts ./dist/${name}/bin/tui`
await $`rm -rf ./dist/${name}/bin/tui`
await Bun.file(`dist/${name}/package.json`).write(
JSON.stringify(
{
name,
version,
os: [os],
os: [os === "windows" ? "win32" : os],
cpu: [arch],
},
null,
2,
),
)
await $`cd dist/${name} && npm publish --access public --tag latest`
if (!dry) await $`cd dist/${name} && npm publish --access public --tag latest`
optionalDependencies[name] = version
}
@@ -65,4 +65,5 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write(
2,
),
)
await $`cd ./dist/${pkg.name} && npm publish --access public --tag latest`
if (!dry)
await $`cd ./dist/${pkg.name} && npm publish --access public --tag latest`