Add binary build system for cross-platform distribution
- Add scripts/build.ts: Bun-based build script for generating binaries
- Support macOS (x64, ARM64, Universal), Windows (x64, ARM64), Linux (x64, ARM64)
- Add build:* npm scripts for each platform (build:mac, build:win, build:linux, etc)
- Configure electron-builder with platform-specific settings:
* macOS: DMG + ZIP, Universal binaries, proper icon paths
* Windows: NSIS installer + ZIP, configurable install directory
* Linux: AppImage + DEB + tar.gz packages
- Add BUILD.md: Comprehensive build documentation with examples
- Update README.md: Add build instructions and reference BUILD.md
- Artifacts named: OpenCode Client-{version}-{os}-{arch}.{ext}
- Output directory: release/
Usage:
bun run build:mac # macOS Universal (Intel + Apple Silicon)
bun run build:win # Windows x64
bun run build:linux # Linux x64
bun run build:all # All platforms
This commit is contained in:
84
scripts/build.ts
Executable file
84
scripts/build.ts
Executable file
@@ -0,0 +1,84 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
import { $ } from "bun"
|
||||
import { existsSync } from "fs"
|
||||
import { join } from "path"
|
||||
|
||||
const platforms = {
|
||||
mac: {
|
||||
args: ["--mac", "--x64", "--arm64", "--universal"],
|
||||
description: "macOS (Intel, Apple Silicon, Universal)",
|
||||
},
|
||||
"mac-x64": {
|
||||
args: ["--mac", "--x64"],
|
||||
description: "macOS (Intel only)",
|
||||
},
|
||||
"mac-arm64": {
|
||||
args: ["--mac", "--arm64"],
|
||||
description: "macOS (Apple Silicon only)",
|
||||
},
|
||||
win: {
|
||||
args: ["--win", "--x64"],
|
||||
description: "Windows (x64)",
|
||||
},
|
||||
"win-arm64": {
|
||||
args: ["--win", "--arm64"],
|
||||
description: "Windows (ARM64)",
|
||||
},
|
||||
linux: {
|
||||
args: ["--linux", "--x64"],
|
||||
description: "Linux (x64)",
|
||||
},
|
||||
"linux-arm64": {
|
||||
args: ["--linux", "--arm64"],
|
||||
description: "Linux (ARM64)",
|
||||
},
|
||||
all: {
|
||||
args: ["--mac", "--win", "--linux", "--x64", "--arm64"],
|
||||
description: "All platforms (macOS, Windows, Linux)",
|
||||
},
|
||||
}
|
||||
|
||||
async function build(platform: string) {
|
||||
const config = platforms[platform as keyof typeof platforms]
|
||||
|
||||
if (!config) {
|
||||
console.error(`❌ Unknown platform: ${platform}`)
|
||||
console.error(`\nAvailable platforms:`)
|
||||
for (const [name, cfg] of Object.entries(platforms)) {
|
||||
console.error(` - ${name.padEnd(12)} : ${cfg.description}`)
|
||||
}
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
console.log(`\n🔨 Building for: ${config.description}\n`)
|
||||
|
||||
try {
|
||||
console.log("📦 Step 1/2: Building Electron app...\n")
|
||||
await $`bun run build`
|
||||
|
||||
console.log("\n📦 Step 2/2: Packaging binaries...\n")
|
||||
const distExists = existsSync(join(process.cwd(), "dist"))
|
||||
if (!distExists) {
|
||||
throw new Error("dist/ directory not found. Build failed.")
|
||||
}
|
||||
|
||||
await $`bunx electron-builder ${config.args}`
|
||||
|
||||
console.log("\n✅ Build complete!")
|
||||
console.log(`📁 Binaries available in: release/\n`)
|
||||
} catch (error) {
|
||||
console.error("\n❌ Build failed:", error)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
const platform = process.argv[2] || "mac"
|
||||
|
||||
console.log(`
|
||||
╔════════════════════════════════════════╗
|
||||
║ OpenCode Client - Binary Builder ║
|
||||
╚════════════════════════════════════════╝
|
||||
`)
|
||||
|
||||
await build(platform)
|
||||
Reference in New Issue
Block a user