2025-05-30 20:47:56 -04:00
|
|
|
#!/usr/bin/env bun
|
2025-10-14 14:34:19 -04:00
|
|
|
import { $ } from "bun"
|
|
|
|
|
import pkg from "../package.json"
|
|
|
|
|
import { Script } from "@opencode-ai/script"
|
2025-11-14 02:38:57 +10:00
|
|
|
import { fileURLToPath } from "url"
|
2025-10-14 14:34:19 -04:00
|
|
|
|
2025-11-14 02:38:57 +10:00
|
|
|
const dir = fileURLToPath(new URL("..", import.meta.url))
|
2025-07-31 01:00:29 -04:00
|
|
|
process.chdir(dir)
|
2025-05-30 20:47:56 -04:00
|
|
|
|
2025-09-19 06:10:27 -04:00
|
|
|
const { binaries } = await import("./build.ts")
|
|
|
|
|
{
|
|
|
|
|
const name = `${pkg.name}-${process.platform}-${process.arch}`
|
|
|
|
|
console.log(`smoke test: running dist/${name}/bin/opencode --version`)
|
|
|
|
|
await $`./dist/${name}/bin/opencode --version`
|
2025-05-30 20:47:56 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await $`mkdir -p ./dist/${pkg.name}`
|
|
|
|
|
await $`cp -r ./bin ./dist/${pkg.name}/bin`
|
2025-06-15 13:10:58 -04:00
|
|
|
await $`cp ./script/postinstall.mjs ./dist/${pkg.name}/postinstall.mjs`
|
2025-11-14 02:38:57 +10:00
|
|
|
|
2025-05-30 20:47:56 -04:00
|
|
|
await Bun.file(`./dist/${pkg.name}/package.json`).write(
|
|
|
|
|
JSON.stringify(
|
|
|
|
|
{
|
|
|
|
|
name: pkg.name + "-ai",
|
|
|
|
|
bin: {
|
2025-11-13 10:22:07 -08:00
|
|
|
[pkg.name]: `./bin/${pkg.name}`,
|
2025-05-30 20:47:56 -04:00
|
|
|
},
|
2025-06-12 00:50:49 -04:00
|
|
|
scripts: {
|
2025-10-31 15:07:36 -04:00
|
|
|
postinstall: "bun ./postinstall.mjs || node ./postinstall.mjs",
|
2025-06-12 00:50:49 -04:00
|
|
|
},
|
2025-10-14 14:34:19 -04:00
|
|
|
version: Script.version,
|
2025-09-19 06:10:27 -04:00
|
|
|
optionalDependencies: binaries,
|
2025-05-30 20:47:56 -04:00
|
|
|
},
|
|
|
|
|
null,
|
|
|
|
|
2,
|
|
|
|
|
),
|
|
|
|
|
)
|
2025-12-09 21:16:00 -05:00
|
|
|
|
2025-12-09 21:39:05 -05:00
|
|
|
const tags = [Script.channel]
|
|
|
|
|
|
2025-12-09 21:16:00 -05:00
|
|
|
const tasks = Object.entries(binaries).map(async ([name]) => {
|
2025-12-09 21:39:05 -05:00
|
|
|
if (process.platform !== "win32") {
|
2025-12-22 16:57:28 +08:00
|
|
|
await $`chmod -R 755 .`.cwd(`./dist/${name}`)
|
2025-12-09 21:39:05 -05:00
|
|
|
}
|
|
|
|
|
await $`bun pm pack`.cwd(`./dist/${name}`)
|
|
|
|
|
for (const tag of tags) {
|
|
|
|
|
await $`npm publish *.tgz --access public --tag ${tag}`.cwd(`./dist/${name}`)
|
2025-11-14 02:38:57 +10:00
|
|
|
}
|
2025-12-09 21:16:00 -05:00
|
|
|
})
|
|
|
|
|
await Promise.all(tasks)
|
2025-12-09 21:39:05 -05:00
|
|
|
for (const tag of tags) {
|
|
|
|
|
await $`cd ./dist/${pkg.name} && bun pm pack && npm publish *.tgz --access public --tag ${tag}`
|
2025-10-28 20:28:30 -04:00
|
|
|
}
|
|
|
|
|
|
2025-10-14 14:34:19 -04:00
|
|
|
if (!Script.preview) {
|
2025-12-19 21:41:18 -06:00
|
|
|
// Create archives for GitHub release
|
|
|
|
|
for (const key of Object.keys(binaries)) {
|
|
|
|
|
if (key.includes("linux")) {
|
|
|
|
|
await $`tar -czf ../../${key}.tar.gz *`.cwd(`dist/${key}/bin`)
|
|
|
|
|
} else {
|
|
|
|
|
await $`zip -r ../../${key}.zip *`.cwd(`dist/${key}/bin`)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-02 16:02:52 -05:00
|
|
|
const image = "ghcr.io/anomalyco/opencode"
|
2025-12-13 20:01:59 +01:00
|
|
|
const platforms = "linux/amd64,linux/arm64"
|
|
|
|
|
const tags = [`${image}:${Script.version}`, `${image}:latest`]
|
|
|
|
|
const tagFlags = tags.flatMap((t) => ["-t", t])
|
|
|
|
|
await $`docker buildx build --platform ${platforms} ${tagFlags} --push .`
|
2025-06-12 11:02:51 -04:00
|
|
|
}
|