Skip to content

Commit 2bee48a

Browse files
committed
homebrew
1 parent 10ddd65 commit 2bee48a

2 files changed

Lines changed: 103 additions & 47 deletions

File tree

packages/opencode/script/PKGBUILD.template

Lines changed: 0 additions & 24 deletions
This file was deleted.

packages/opencode/script/publish.ts

Lines changed: 103 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -118,30 +118,52 @@ if (!snapshot) {
118118
if (!dry)
119119
await $`gh release create v${version} --title "v${version}" --notes ${notes} ./dist/*.zip`
120120

121+
// Calculate SHA values
122+
const arm64Sha =
123+
await $`sha256sum ./dist/opencode-linux-arm64.zip | cut -d' ' -f1`
124+
.text()
125+
.then((x) => x.trim())
126+
const x64Sha =
127+
await $`sha256sum ./dist/opencode-linux-x64.zip | cut -d' ' -f1`
128+
.text()
129+
.then((x) => x.trim())
130+
const macX64Sha =
131+
await $`sha256sum ./dist/opencode-darwin-x64.zip | cut -d' ' -f1`
132+
.text()
133+
.then((x) => x.trim())
134+
const macArm64Sha =
135+
await $`sha256sum ./dist/opencode-darwin-arm64.zip | cut -d' ' -f1`
136+
.text()
137+
.then((x) => x.trim())
138+
121139
// AUR package
122-
const pkgbuildTemplate = await Bun.file("./script/PKGBUILD.template").text()
123-
const pkgbuild = pkgbuildTemplate
124-
.replace("{{VERSION}}", version.split("-")[0])
125-
.replace(
126-
"{{ARM64_URL}}",
127-
`https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-arm64.zip`,
128-
)
129-
.replace(
130-
"{{ARM64_SHA}}",
131-
await $`sha256sum ./dist/opencode-linux-arm64.zip | cut -d' ' -f1`
132-
.text()
133-
.then((x) => x.trim()),
134-
)
135-
.replace(
136-
"{{X64_URL}}",
137-
`https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-x64.zip`,
138-
)
139-
.replace(
140-
"{{X64_SHA}}",
141-
await $`sha256sum ./dist/opencode-linux-x64.zip | cut -d' ' -f1`
142-
.text()
143-
.then((x) => x.trim()),
144-
)
140+
const pkgbuild = [
141+
"# Maintainer: dax",
142+
"# Maintainer: adam",
143+
"",
144+
"pkgname='opencode-bin'",
145+
`pkgver=${version.split("-")[0]}`,
146+
"options=('!debug' '!strip')",
147+
"pkgrel=1",
148+
"pkgdesc='The AI coding agent built for the terminal.'",
149+
"url='https://github.com/sst/opencode'",
150+
"arch=('aarch64' 'x86_64')",
151+
"license=('MIT')",
152+
"provides=('opencode')",
153+
"conflicts=('opencode')",
154+
"depends=('fzf' 'ripgrep')",
155+
"",
156+
`source_aarch64=("\${pkgname}_\${pkgver}_aarch64.zip::https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-arm64.zip")`,
157+
`sha256sums_aarch64=('${arm64Sha}')`,
158+
"",
159+
`source_x86_64=("\${pkgname}_\${pkgver}_x86_64.zip::https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-x64.zip")`,
160+
`sha256sums_x86_64=('${x64Sha}')`,
161+
"",
162+
"package() {",
163+
' install -Dm755 ./opencode "${pkgdir}/usr/bin/opencode"',
164+
"}",
165+
"",
166+
].join("\n")
145167

146168
await $`rm -rf ./dist/aur-opencode-bin`
147169

@@ -151,4 +173,62 @@ if (!snapshot) {
151173
await $`cd ./dist/aur-opencode-bin && git add PKGBUILD .SRCINFO`
152174
await $`cd ./dist/aur-opencode-bin && git commit -m "Update to v${version}"`
153175
if (!dry) await $`cd ./dist/aur-opencode-bin && git push`
176+
177+
// Homebrew formula
178+
const homebrewFormula = [
179+
"# typed: false",
180+
"# frozen_string_literal: true",
181+
"",
182+
"# This file was generated by GoReleaser. DO NOT EDIT.",
183+
"class Opencode < Formula",
184+
` desc "The AI coding agent built for the terminal."`,
185+
` homepage "https://github.com/sst/opencode"`,
186+
` version "${version.split("-")[0]}"`,
187+
"",
188+
" on_macos do",
189+
" if Hardware::CPU.intel?",
190+
` url "https://github.com/sst/opencode/releases/download/v${version}/opencode-darwin-x64.zip"`,
191+
` sha256 "${macX64Sha}"`,
192+
"",
193+
" def install",
194+
' bin.install "opencode"',
195+
" end",
196+
" end",
197+
" if Hardware::CPU.arm?",
198+
` url "https://github.com/sst/opencode/releases/download/v${version}/opencode-darwin-arm64.zip"`,
199+
` sha256 "${macArm64Sha}"`,
200+
"",
201+
" def install",
202+
' bin.install "opencode"',
203+
" end",
204+
" end",
205+
" end",
206+
"",
207+
" on_linux do",
208+
" if Hardware::CPU.intel? and Hardware::CPU.is_64_bit?",
209+
` url "https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-x64.zip"`,
210+
` sha256 "${x64Sha}"`,
211+
" def install",
212+
' bin.install "opencode"',
213+
" end",
214+
" end",
215+
" if Hardware::CPU.arm? and Hardware::CPU.is_64_bit?",
216+
` url "https://github.com/sst/opencode/releases/download/v${version}/opencode-linux-arm64.zip"`,
217+
` sha256 "${arm64Sha}"`,
218+
" def install",
219+
' bin.install "opencode"',
220+
" end",
221+
" end",
222+
" end",
223+
"end",
224+
"",
225+
"",
226+
].join("\n")
227+
228+
await $`rm -rf ./dist/homebrew-tap`
229+
await $`git clone git@github.com:sst/homebrew-tap.git ./dist/homebrew-tap`
230+
await Bun.file("./dist/homebrew-tap/opencode.rb").write(homebrewFormula)
231+
await $`cd ./dist/homebrew-tap && git add opencode.rb`
232+
await $`cd ./dist/homebrew-tap && git commit -m "Update to v${version}"`
233+
if (!dry) await $`cd ./dist/homebrew-tap && git push`
154234
}

0 commit comments

Comments
 (0)