This commit is contained in:
Dax Raad 2025-06-13 16:17:27 -04:00
parent 10ddd654cf
commit 2bee48a9bc
2 changed files with 103 additions and 47 deletions

View file

@ -1,24 +0,0 @@
# Maintainer: dax
# Maintainer: adam
pkgname='opencode-bin'
pkgver={{VERSION}}
options=('!debug' '!strip')
pkgrel=1
pkgdesc='The AI coding agent built for the terminal.'
url='https://github.com/sst/opencode'
arch=('aarch64' 'x86_64')
license=('MIT')
provides=('opencode')
conflicts=('opencode')
depends=('fzf' 'ripgrep')
source_aarch64=("${pkgname}_${pkgver}_aarch64.zip::{{ARM64_URL}}")
sha256sums_aarch64=('{{ARM64_SHA}}')
source_x86_64=("${pkgname}_${pkgver}_x86_64.zip::{{X64_URL}}")
sha256sums_x86_64=('{{X64_SHA}}')
package() {
install -Dm755 ./opencode "${pkgdir}/usr/bin/opencode"
}

View file

@ -118,30 +118,52 @@ if (!snapshot) {
if (!dry) if (!dry)
await $`gh release create v${version} --title "v${version}" --notes ${notes} ./dist/*.zip` await $`gh release create v${version} --title "v${version}" --notes ${notes} ./dist/*.zip`
// Calculate SHA values
const arm64Sha =
await $`sha256sum ./dist/opencode-linux-arm64.zip | cut -d' ' -f1`
.text()
.then((x) => x.trim())
const x64Sha =
await $`sha256sum ./dist/opencode-linux-x64.zip | 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())
// AUR package // AUR package
const pkgbuildTemplate = await Bun.file("./script/PKGBUILD.template").text() const pkgbuild = [
const pkgbuild = pkgbuildTemplate "# Maintainer: dax",
.replace("{{VERSION}}", version.split("-")[0]) "# Maintainer: adam",
.replace( "",
"{{ARM64_URL}}", "pkgname='opencode-bin'",
`https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-arm64.zip`, `pkgver=${version.split("-")[0]}`,
) "options=('!debug' '!strip')",
.replace( "pkgrel=1",
"{{ARM64_SHA}}", "pkgdesc='The AI coding agent built for the terminal.'",
await $`sha256sum ./dist/opencode-linux-arm64.zip | cut -d' ' -f1` "url='https://github.com/sst/opencode'",
.text() "arch=('aarch64' 'x86_64')",
.then((x) => x.trim()), "license=('MIT')",
) "provides=('opencode')",
.replace( "conflicts=('opencode')",
"{{X64_URL}}", "depends=('fzf' 'ripgrep')",
`https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-x64.zip`, "",
) `source_aarch64=("\${pkgname}_\${pkgver}_aarch64.zip::https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-arm64.zip")`,
.replace( `sha256sums_aarch64=('${arm64Sha}')`,
"{{X64_SHA}}", "",
await $`sha256sum ./dist/opencode-linux-x64.zip | cut -d' ' -f1` `source_x86_64=("\${pkgname}_\${pkgver}_x86_64.zip::https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-x64.zip")`,
.text() `sha256sums_x86_64=('${x64Sha}')`,
.then((x) => x.trim()), "",
) "package() {",
' install -Dm755 ./opencode "${pkgdir}/usr/bin/opencode"',
"}",
"",
].join("\n")
await $`rm -rf ./dist/aur-opencode-bin` await $`rm -rf ./dist/aur-opencode-bin`
@ -151,4 +173,62 @@ if (!snapshot) {
await $`cd ./dist/aur-opencode-bin && git add PKGBUILD .SRCINFO` await $`cd ./dist/aur-opencode-bin && git add PKGBUILD .SRCINFO`
await $`cd ./dist/aur-opencode-bin && git commit -m "Update to v${version}"` await $`cd ./dist/aur-opencode-bin && git commit -m "Update to v${version}"`
if (!dry) await $`cd ./dist/aur-opencode-bin && git push` if (!dry) await $`cd ./dist/aur-opencode-bin && git push`
// Homebrew formula
const homebrewFormula = [
"# typed: false",
"# frozen_string_literal: true",
"",
"# This file was generated by GoReleaser. DO NOT EDIT.",
"class Opencode < Formula",
` desc "The AI coding agent built for the terminal."`,
` homepage "https://github.com/sst/opencode"`,
` version "${version.split("-")[0]}"`,
"",
" on_macos do",
" if Hardware::CPU.intel?",
` url "https://github.com/sst/opencode/releases/download/v${version}/opencode-darwin-x64.zip"`,
` sha256 "${macX64Sha}"`,
"",
" def install",
' bin.install "opencode"',
" end",
" end",
" if Hardware::CPU.arm?",
` url "https://github.com/sst/opencode/releases/download/v${version}/opencode-darwin-arm64.zip"`,
` sha256 "${macArm64Sha}"`,
"",
" def install",
' bin.install "opencode"',
" end",
" end",
" end",
"",
" on_linux do",
" if Hardware::CPU.intel? and Hardware::CPU.is_64_bit?",
` url "https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-x64.zip"`,
` sha256 "${x64Sha}"`,
" def install",
' bin.install "opencode"',
" end",
" end",
" if Hardware::CPU.arm? and Hardware::CPU.is_64_bit?",
` url "https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-arm64.zip"`,
` sha256 "${arm64Sha}"`,
" def install",
' bin.install "opencode"',
" end",
" end",
" end",
"end",
"",
"",
].join("\n")
await $`rm -rf ./dist/homebrew-tap`
await $`git clone git@github.com:sst/homebrew-tap.git ./dist/homebrew-tap`
await Bun.file("./dist/homebrew-tap/opencode.rb").write(homebrewFormula)
await $`cd ./dist/homebrew-tap && git add opencode.rb`
await $`cd ./dist/homebrew-tap && git commit -m "Update to v${version}"`
if (!dry) await $`cd ./dist/homebrew-tap && git push`
} }