Skip to content

Commit d9c7ac6

Browse files
committed
tweak
1 parent 3ec116e commit d9c7ac6

1 file changed

Lines changed: 69 additions & 61 deletions

File tree

‎packages/opencode/script/publish.ts‎

Lines changed: 69 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ if (!Script.preview && !dryRun) {
6767
await $`cd ./dist/${pkg.name} && npm dist-tag add ${pkg.name}-ai@${Script.version} ${majorTag}`
6868
}
6969

70-
if (!Script.preview && !dryRun) {
70+
if (!Script.preview || dryRun) {
7171
for (const key of Object.keys(binaries)) {
7272
await $`cd dist/${key}/bin && zip -r ../../${key}.zip *`
7373
}
@@ -180,75 +180,83 @@ if (!Script.preview && !dryRun) {
180180
for (let i = 0; i < 30; i++) {
181181
try {
182182
await $`rm -rf ./dist/aur-${pkg}`
183-
await $`git clone ssh://[email protected]/${pkg}.git ./dist/aur-${pkg}`
183+
const aurUrl = dryRun ? `https://aur.archlinux.org/${pkg}.git` : `ssh://[email protected]/${pkg}.git`
184+
await $`git clone ${aurUrl} ./dist/aur-${pkg}`
184185
await $`cd ./dist/aur-${pkg} && git checkout master`
185186
await Bun.file(`./dist/aur-${pkg}/PKGBUILD`).write(pkgbuild)
186187
await $`cd ./dist/aur-${pkg} && makepkg --printsrcinfo > .SRCINFO`
187-
await $`cd ./dist/aur-${pkg} && git add PKGBUILD .SRCINFO`
188-
await $`cd ./dist/aur-${pkg} && git commit -m "Update to v${Script.version}"`
189-
await $`cd ./dist/aur-${pkg} && git push`
188+
if (!dryRun) {
189+
await $`cd ./dist/aur-${pkg} && git add PKGBUILD .SRCINFO`
190+
await $`cd ./dist/aur-${pkg} && git commit -m "Update to v${Script.version}"`
191+
await $`cd ./dist/aur-${pkg} && git push`
192+
}
193+
if (dryRun) {
194+
console.log(`DRY_RUN: skipping git commit/push for ${pkg}`)
195+
}
190196
break
191197
} catch (e) {
192198
continue
193199
}
194200
}
195201
}
196202

197-
// Homebrew formula
198-
const homebrewFormula = [
199-
"# typed: false",
200-
"# frozen_string_literal: true",
201-
"",
202-
"# This file was generated by GoReleaser. DO NOT EDIT.",
203-
"class Opencode < Formula",
204-
` desc "The AI coding agent built for the terminal."`,
205-
` homepage "https://github.com/sst/opencode"`,
206-
` version "${Script.version.split("-")[0]}"`,
207-
"",
208-
" on_macos do",
209-
" if Hardware::CPU.intel?",
210-
` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-darwin-x64.zip"`,
211-
` sha256 "${macX64Sha}"`,
212-
"",
213-
" def install",
214-
' bin.install "opencode"',
215-
" end",
216-
" end",
217-
" if Hardware::CPU.arm?",
218-
` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-darwin-arm64.zip"`,
219-
` sha256 "${macArm64Sha}"`,
220-
"",
221-
" def install",
222-
' bin.install "opencode"',
223-
" end",
224-
" end",
225-
" end",
226-
"",
227-
" on_linux do",
228-
" if Hardware::CPU.intel? and Hardware::CPU.is_64_bit?",
229-
` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-linux-x64.zip"`,
230-
` sha256 "${x64Sha}"`,
231-
" def install",
232-
' bin.install "opencode"',
233-
" end",
234-
" end",
235-
" if Hardware::CPU.arm? and Hardware::CPU.is_64_bit?",
236-
` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-linux-arm64.zip"`,
237-
` sha256 "${arm64Sha}"`,
238-
" def install",
239-
' bin.install "opencode"',
240-
" end",
241-
" end",
242-
" end",
243-
"end",
244-
"",
245-
"",
246-
].join("\n")
203+
if (!Script.preview && !dryRun) {
204+
// Homebrew formula
205+
const homebrewFormula = [
206+
"# typed: false",
207+
"# frozen_string_literal: true",
208+
"",
209+
"# This file was generated by GoReleaser. DO NOT EDIT.",
210+
"class Opencode < Formula",
211+
` desc "The AI coding agent built for the terminal."`,
212+
` homepage "https://github.com/sst/opencode"`,
213+
` version "${Script.version.split("-")[0]}"`,
214+
"",
215+
" on_macos do",
216+
" if Hardware::CPU.intel?",
217+
` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-darwin-x64.zip"`,
218+
` sha256 "${macX64Sha}"`,
219+
"",
220+
" def install",
221+
' bin.install "opencode"',
222+
" end",
223+
" end",
224+
" if Hardware::CPU.arm?",
225+
` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-darwin-arm64.zip"`,
226+
` sha256 "${macArm64Sha}"`,
227+
"",
228+
" def install",
229+
' bin.install "opencode"',
230+
" end",
231+
" end",
232+
" end",
233+
"",
234+
" on_linux do",
235+
" if Hardware::CPU.intel? and Hardware::CPU.is_64_bit?",
236+
` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-linux-x64.zip"`,
237+
` sha256 "${x64Sha}"`,
238+
" def install",
239+
' bin.install "opencode"',
240+
" end",
241+
" end",
242+
" if Hardware::CPU.arm? and Hardware::CPU.is_64_bit?",
243+
` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-linux-arm64.zip"`,
244+
` sha256 "${arm64Sha}"`,
245+
" def install",
246+
' bin.install "opencode"',
247+
" end",
248+
" end",
249+
" end",
250+
"end",
251+
"",
252+
"",
253+
].join("\n")
247254

248-
await $`rm -rf ./dist/homebrew-tap`
249-
await $`git clone https://${process.env["GITHUB_TOKEN"]}@github.com/sst/homebrew-tap.git ./dist/homebrew-tap`
250-
await Bun.file("./dist/homebrew-tap/opencode.rb").write(homebrewFormula)
251-
await $`cd ./dist/homebrew-tap && git add opencode.rb`
252-
await $`cd ./dist/homebrew-tap && git commit -m "Update to v${Script.version}"`
253-
await $`cd ./dist/homebrew-tap && git push`
255+
await $`rm -rf ./dist/homebrew-tap`
256+
await $`git clone https://${process.env["GITHUB_TOKEN"]}@github.com/sst/homebrew-tap.git ./dist/homebrew-tap`
257+
await Bun.file("./dist/homebrew-tap/opencode.rb").write(homebrewFormula)
258+
await $`cd ./dist/homebrew-tap && git add opencode.rb`
259+
await $`cd ./dist/homebrew-tap && git commit -m "Update to v${Script.version}"`
260+
await $`cd ./dist/homebrew-tap && git push`
261+
}
254262
}

0 commit comments

Comments
 (0)