fix: fix build and publish scripts

This commit is contained in:
Catriel Müller
2026-03-17 08:00:58 -03:00
parent eb662661ca
commit f2d9599c3a
2 changed files with 69 additions and 31 deletions
+32 -5
View File
@@ -179,8 +179,8 @@ for (const item of targets) {
autoloadTsconfig: true,
autoloadPackageJson: true,
target: name.replace(pkg.name, "bun") as any,
outfile: `dist/${name}/bin/opencode`,
execArgv: [`--user-agent=opencode/${Script.version}`, "--use-system-ca", "--"],
outfile: `dist/${name}/bin/kilo`, // kilocode_change
execArgv: [`--user-agent=kilo/${Script.version}`, "--use-system-ca", "--"], // kilocode_change
windows: {},
},
entrypoints: ["./src/index.ts", parserWorker, workerPath],
@@ -194,6 +194,27 @@ for (const item of targets) {
},
})
// kilocode_change start - fix Nix-specific ELF interpreter paths for Linux binaries
if (item.os === "linux") {
const interpreters: Record<string, string> = {
x64: "/lib64/ld-linux-x86-64.so.2",
arm64: "/lib/ld-linux-aarch64.so.1",
"x64-musl": "/lib/ld-musl-x86_64.so.1",
"arm64-musl": "/lib/ld-musl-aarch64.so.1",
}
const key = item.abi === "musl" ? `${item.arch}-musl` : item.arch
const interpreter = interpreters[key]
if (interpreter) {
try {
await $`patchelf --set-interpreter ${interpreter} dist/${name}/bin/kilo`
console.log(`patched interpreter for ${name} -> ${interpreter}`)
} catch {
console.warn(`patchelf not available, skipping interpreter fix for ${name}`)
}
}
}
// kilocode_change end
await $`rm -rf ./dist/${name}/bin/tui`
await Bun.file(`dist/${name}/package.json`).write(
JSON.stringify(
@@ -217,14 +238,20 @@ for (const item of targets) {
}
if (Script.release) {
const archives: string[] = [] // kilocode_change
for (const key of Object.keys(binaries)) {
const archive = key.replace(pkg.name, "kilo") // kilocode_change
if (key.includes("linux")) {
await $`tar -czf ../../${key}.tar.gz *`.cwd(`dist/${key}/bin`)
const out = path.resolve("dist", `${archive}.tar.gz`) // kilocode_change
await $`tar -czf ${out} *`.cwd(`dist/${key}/bin`) // kilocode_change
archives.push(out) // kilocode_change
} else {
await $`zip -r ../../${key}.zip *`.cwd(`dist/${key}/bin`)
const out = path.resolve("dist", `${archive}.zip`) // kilocode_change
await $`zip -r ${out} *`.cwd(`dist/${key}/bin`) // kilocode_change
archives.push(out) // kilocode_change
}
}
await $`gh release upload v${Script.version} ./dist/*.zip ./dist/*.tar.gz --clobber --repo ${process.env.GH_REPO}`
await $`gh release upload v${Script.version} ${archives} --clobber` // kilocode_change
}
export { binaries }
+37 -26
View File
@@ -21,13 +21,17 @@ await $`mkdir -p ./dist/${pkg.name}`
await $`cp -r ./bin ./dist/${pkg.name}/bin`
await $`cp ./script/postinstall.mjs ./dist/${pkg.name}/postinstall.mjs`
await Bun.file(`./dist/${pkg.name}/LICENSE`).write(await Bun.file("../../LICENSE").text())
await Bun.file(`./dist/${pkg.name}/README.md`).write(await Bun.file("./README.md").text()) // kilocode_change
await Bun.file(`./dist/${pkg.name}/package.json`).write(
JSON.stringify(
{
name: pkg.name + "-ai",
name: pkg.name, // kilocode_change
bin: {
[pkg.name]: `./bin/${pkg.name}`,
// kilocode_change start
kilo: `./bin/kilo`,
kilocode: `./bin/kilo`,
// kilocode_change end
},
scripts: {
postinstall: "bun ./postinstall.mjs || node ./postinstall.mjs",
@@ -35,6 +39,12 @@ await Bun.file(`./dist/${pkg.name}/package.json`).write(
version: version,
license: pkg.license,
optionalDependencies: binaries,
// kilocode_change start
repository: {
type: "git",
url: "https://github.com/Kilo-Org/kilocode",
},
// kilocode_change end
},
null,
2,
@@ -46,12 +56,12 @@ const tasks = Object.entries(binaries).map(async ([name]) => {
await $`chmod -R 755 .`.cwd(`./dist/${name}`)
}
await $`bun pm pack`.cwd(`./dist/${name}`)
await $`npm publish *.tgz --access public --tag ${Script.channel}`.cwd(`./dist/${name}`)
await $`npm publish *.tgz --access public --tag ${Script.channel} --provenance`.cwd(`./dist/${name}`) // kilocode_change
})
await Promise.all(tasks)
await $`cd ./dist/${pkg.name} && bun pm pack && npm publish *.tgz --access public --tag ${Script.channel}`
await $`cd ./dist/${pkg.name} && bun pm pack && npm publish *.tgz --access public --tag ${Script.channel} --provenance` // kilocode_change
const image = "ghcr.io/Kilo-Org/kilocode"
const image = "ghcr.io/kilo-org/kilo" // kilocode_change
const platforms = "linux/amd64,linux/arm64"
const tags = [`${image}:${version}`, `${image}:${Script.channel}`]
const tagFlags = tags.flatMap((t) => ["-t", t])
@@ -60,19 +70,20 @@ await $`docker buildx build --platform ${platforms} ${tagFlags} --push .`
// registries
if (!Script.preview) {
// Calculate SHA values
const arm64Sha = await $`sha256sum ./dist/opencode-linux-arm64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim())
const x64Sha = await $`sha256sum ./dist/opencode-linux-x64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim())
const macX64Sha = await $`sha256sum ./dist/opencode-darwin-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim())
const macArm64Sha = await $`sha256sum ./dist/opencode-darwin-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim())
// kilocode_change start
const arm64Sha = await $`sha256sum ./dist/kilo-linux-arm64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim())
const x64Sha = await $`sha256sum ./dist/kilo-linux-x64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim())
const macX64Sha = await $`sha256sum ./dist/kilo-darwin-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim())
const macArm64Sha = await $`sha256sum ./dist/kilo-darwin-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim())
// kilocode_change end
const [pkgver, _subver = ""] = Script.version.split(/(-.*)/, 2)
// arch
const binaryPkgbuild = [
"# Maintainer: dax",
"# Maintainer: adam",
"# Maintainer: kilo", // kilocode_change
"",
"pkgname='opencode-bin'",
"pkgname='kilo-bin'",
`pkgver=${pkgver}`,
`_subver=${_subver}`,
"options=('!debug' '!strip')",
@@ -85,19 +96,19 @@ if (!Script.preview) {
"conflicts=('kilo')",
"depends=('ripgrep')",
"",
`source_aarch64=("\${pkgname}_\${pkgver}_aarch64.tar.gz::https://github.com/Kilo-Org/kilocode/releases/download/v\${pkgver}\${_subver}/opencode-linux-arm64.tar.gz")`,
`source_aarch64=("\${pkgname}_\${pkgver}_aarch64.tar.gz::https://github.com/Kilo-Org/kilocode/releases/download/v\${pkgver}\${_subver}/kilo-linux-arm64.tar.gz")`,
`sha256sums_aarch64=('${arm64Sha}')`,
`source_x86_64=("\${pkgname}_\${pkgver}_x86_64.tar.gz::https://github.com/Kilo-Org/kilocode/releases/download/v\${pkgver}\${_subver}/opencode-linux-x64.tar.gz")`,
`source_x86_64=("\${pkgname}_\${pkgver}_x86_64.tar.gz::https://github.com/Kilo-Org/kilocode/releases/download/v\${pkgver}\${_subver}/kilo-linux-x64.tar.gz")`,
`sha256sums_x86_64=('${x64Sha}')`,
"",
"package() {",
' install -Dm755 ./opencode "${pkgdir}/usr/bin/opencode"',
' install -Dm755 ./kilo "${pkgdir}/usr/bin/kilo"',
"}",
"",
].join("\n")
for (const [pkg, pkgbuild] of [["opencode-bin", binaryPkgbuild]]) {
for (const [pkg, pkgbuild] of [["kilo-bin", binaryPkgbuild]]) {
for (let i = 0; i < 30; i++) {
try {
await $`rm -rf ./dist/aur-${pkg}`
@@ -121,45 +132,45 @@ if (!Script.preview) {
"# frozen_string_literal: true",
"",
"# This file was generated by GoReleaser. DO NOT EDIT.",
"class Opencode < Formula",
"class Kilo < Formula", // kilocode_change
` desc "The AI coding agent built for the terminal."`,
` homepage "https://github.com/Kilo-Org/kilocode"`,
` homepage "https://kilo.ai"`, // kilocode_change
` version "${Script.version.split("-")[0]}"`,
"",
` depends_on "ripgrep"`,
"",
" on_macos do",
" if Hardware::CPU.intel?",
` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/opencode-darwin-x64.zip"`,
` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/kilo-darwin-x64.zip"`,
` sha256 "${macX64Sha}"`,
"",
" def install",
' bin.install "opencode"',
' bin.install "kilo"',
" end",
" end",
" if Hardware::CPU.arm?",
` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/opencode-darwin-arm64.zip"`,
` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/kilo-darwin-arm64.zip"`,
` sha256 "${macArm64Sha}"`,
"",
" def install",
' bin.install "opencode"',
' bin.install "kilo"',
" end",
" end",
" end",
"",
" on_linux do",
" if Hardware::CPU.intel? and Hardware::CPU.is_64_bit?",
` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/opencode-linux-x64.tar.gz"`,
` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/kilo-linux-x64.tar.gz"`,
` sha256 "${x64Sha}"`,
" def install",
' bin.install "opencode"',
' bin.install "kilo"',
" end",
" end",
" if Hardware::CPU.arm? and Hardware::CPU.is_64_bit?",
` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/opencode-linux-arm64.tar.gz"`,
` url "https://github.com/Kilo-Org/kilocode/releases/download/v${Script.version}/kilo-linux-arm64.tar.gz"`,
` sha256 "${arm64Sha}"`,
" def install",
' bin.install "opencode"',
' bin.install "kilo"',
" end",
" end",
" end",