Skip to content

Commit 943fbf3

Browse files
ci: separate standalone publishing from dependent publishing (anomalyco#5634)
Co-authored-by: GitHub Action <action@github.com>
1 parent d8a34c2 commit 943fbf3

6 files changed

Lines changed: 221 additions & 207 deletions

File tree

.github/workflows/publish.yml

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,6 @@ jobs:
4141

4242
- uses: ./.github/actions/setup-bun
4343

44-
- name: Setup SSH for AUR
45-
if: inputs.bump || inputs.version
46-
run: |
47-
sudo apt-get update
48-
sudo apt-get install -y pacman-package-manager
49-
mkdir -p ~/.ssh
50-
echo "${{ secrets.AUR_KEY }}" > ~/.ssh/id_rsa
51-
chmod 600 ~/.ssh/id_rsa
52-
git config --global user.email "opencode@sst.dev"
53-
git config --global user.name "opencode"
54-
ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true
55-
5644
- name: Install OpenCode
5745
if: inputs.bump || inputs.version
5846
run: bun i -g opencode-ai@1.0.169
@@ -77,7 +65,7 @@ jobs:
7765

7866
- name: Publish
7967
id: publish
80-
run: ./script/publish.ts
68+
run: ./script/publish-start.ts
8169
env:
8270
OPENCODE_BUMP: ${{ inputs.bump }}
8371
OPENCODE_VERSION: ${{ inputs.version }}
@@ -212,6 +200,23 @@ jobs:
212200
fetch-depth: 0
213201
ref: ${{ needs.publish.outputs.tagName }}
214202

215-
- run: gh release edit ${{ needs.publish.outputs.tagName }} --draft=false
203+
- uses: ./.github/actions/setup-bun
204+
205+
- name: Setup SSH for AUR
206+
run: |
207+
sudo apt-get update
208+
sudo apt-get install -y pacman-package-manager
209+
mkdir -p ~/.ssh
210+
echo "${{ secrets.AUR_KEY }}" > ~/.ssh/id_rsa
211+
chmod 600 ~/.ssh/id_rsa
212+
git config --global user.email "opencode@sst.dev"
213+
git config --global user.name "opencode"
214+
ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true
215+
216+
- run: ./script/publish-complete.ts
216217
env:
217-
GH_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
218+
OPENCODE_BUMP: ${{ inputs.bump }}
219+
OPENCODE_VERSION: ${{ inputs.version }}
220+
AUR_KEY: ${{ secrets.AUR_KEY }}
221+
GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
222+
OPENCODE_RELEASE_TAG: ${{ needs.publish.outputs.tagName }}

.opencode/agent/triage.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ TUI issues potentially caused by our underlying TUI library:
6363

6464
**Do not** add for general TUI bugs.
6565

66-
---
67-
6866
When assigning to people here are the following rules:
6967

7068
adamdotdev:
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#!/usr/bin/env bun
2+
import { $ } from "bun"
3+
import { Script } from "@opencode-ai/script"
4+
5+
if (!Script.preview) {
6+
// Calculate SHA values
7+
const arm64Sha = await $`sha256sum ./dist/opencode-linux-arm64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim())
8+
const x64Sha = await $`sha256sum ./dist/opencode-linux-x64.tar.gz | cut -d' ' -f1`.text().then((x) => x.trim())
9+
const macX64Sha = await $`sha256sum ./dist/opencode-darwin-x64.zip | cut -d' ' -f1`.text().then((x) => x.trim())
10+
const macArm64Sha = await $`sha256sum ./dist/opencode-darwin-arm64.zip | cut -d' ' -f1`.text().then((x) => x.trim())
11+
12+
const [pkgver, _subver = ""] = Script.version.split(/(-.*)/, 2)
13+
14+
// arch
15+
const binaryPkgbuild = [
16+
"# Maintainer: dax",
17+
"# Maintainer: adam",
18+
"",
19+
"pkgname='opencode-bin'",
20+
`pkgver=${pkgver}`,
21+
`_subver=${_subver}`,
22+
"options=('!debug' '!strip')",
23+
"pkgrel=1",
24+
"pkgdesc='The AI coding agent built for the terminal.'",
25+
"url='https://github.com/sst/opencode'",
26+
"arch=('aarch64' 'x86_64')",
27+
"license=('MIT')",
28+
"provides=('opencode')",
29+
"conflicts=('opencode')",
30+
"depends=('ripgrep')",
31+
"",
32+
`source_aarch64=("\${pkgname}_\${pkgver}_aarch64.tar.gz::https://github.com/sst/opencode/releases/download/v\${pkgver}\${_subver}/opencode-linux-arm64.tar.gz")`,
33+
`sha256sums_aarch64=('${arm64Sha}')`,
34+
35+
`source_x86_64=("\${pkgname}_\${pkgver}_x86_64.tar.gz::https://github.com/sst/opencode/releases/download/v\${pkgver}\${_subver}/opencode-linux-x64.tar.gz")`,
36+
`sha256sums_x86_64=('${x64Sha}')`,
37+
"",
38+
"package() {",
39+
' install -Dm755 ./opencode "${pkgdir}/usr/bin/opencode"',
40+
"}",
41+
"",
42+
].join("\n")
43+
44+
// Source-based PKGBUILD for opencode
45+
const sourcePkgbuild = [
46+
"# Maintainer: dax",
47+
"# Maintainer: adam",
48+
"",
49+
"pkgname='opencode'",
50+
`pkgver=${pkgver}`,
51+
`_subver=${_subver}`,
52+
"options=('!debug' '!strip')",
53+
"pkgrel=1",
54+
"pkgdesc='The AI coding agent built for the terminal.'",
55+
"url='https://github.com/sst/opencode'",
56+
"arch=('aarch64' 'x86_64')",
57+
"license=('MIT')",
58+
"provides=('opencode')",
59+
"conflicts=('opencode-bin')",
60+
"depends=('ripgrep')",
61+
"makedepends=('git' 'bun-bin' 'go')",
62+
"",
63+
`source=("opencode-\${pkgver}.tar.gz::https://github.com/sst/opencode/archive/v\${pkgver}\${_subver}.tar.gz")`,
64+
`sha256sums=('SKIP')`,
65+
"",
66+
"build() {",
67+
` cd "opencode-\${pkgver}"`,
68+
` bun install`,
69+
" cd ./packages/opencode",
70+
` OPENCODE_CHANNEL=latest OPENCODE_VERSION=${pkgver} bun run ./script/build.ts --single`,
71+
"}",
72+
"",
73+
"package() {",
74+
` cd "opencode-\${pkgver}/packages/opencode"`,
75+
' mkdir -p "${pkgdir}/usr/bin"',
76+
' target_arch="x64"',
77+
' case "$CARCH" in',
78+
' x86_64) target_arch="x64" ;;',
79+
' aarch64) target_arch="arm64" ;;',
80+
' *) printf "unsupported architecture: %s\\n" "$CARCH" >&2 ; return 1 ;;',
81+
" esac",
82+
' libc=""',
83+
" if command -v ldd >/dev/null 2>&1; then",
84+
" if ldd --version 2>&1 | grep -qi musl; then",
85+
' libc="-musl"',
86+
" fi",
87+
" fi",
88+
' if [ -z "$libc" ] && ls /lib/ld-musl-* >/dev/null 2>&1; then',
89+
' libc="-musl"',
90+
" fi",
91+
' base=""',
92+
' if [ "$target_arch" = "x64" ]; then',
93+
" if ! grep -qi avx2 /proc/cpuinfo 2>/dev/null; then",
94+
' base="-baseline"',
95+
" fi",
96+
" fi",
97+
' bin="dist/opencode-linux-${target_arch}${base}${libc}/bin/opencode"',
98+
' if [ ! -f "$bin" ]; then',
99+
' printf "unable to find binary for %s%s%s\\n" "$target_arch" "$base" "$libc" >&2',
100+
" return 1",
101+
" fi",
102+
' install -Dm755 "$bin" "${pkgdir}/usr/bin/opencode"',
103+
"}",
104+
"",
105+
].join("\n")
106+
107+
for (const [pkg, pkgbuild] of [
108+
["opencode-bin", binaryPkgbuild],
109+
["opencode", sourcePkgbuild],
110+
]) {
111+
for (let i = 0; i < 30; i++) {
112+
try {
113+
await $`rm -rf ./dist/aur-${pkg}`
114+
await $`git clone ssh://aur@aur.archlinux.org/${pkg}.git ./dist/aur-${pkg}`
115+
await $`cd ./dist/aur-${pkg} && git checkout master`
116+
await Bun.file(`./dist/aur-${pkg}/PKGBUILD`).write(pkgbuild)
117+
await $`cd ./dist/aur-${pkg} && makepkg --printsrcinfo > .SRCINFO`
118+
await $`cd ./dist/aur-${pkg} && git add PKGBUILD .SRCINFO`
119+
await $`cd ./dist/aur-${pkg} && git commit -m "Update to v${Script.version}"`
120+
await $`cd ./dist/aur-${pkg} && git push`
121+
break
122+
} catch (e) {
123+
continue
124+
}
125+
}
126+
}
127+
128+
// Homebrew formula
129+
const homebrewFormula = [
130+
"# typed: false",
131+
"# frozen_string_literal: true",
132+
"",
133+
"# This file was generated by GoReleaser. DO NOT EDIT.",
134+
"class Opencode < Formula",
135+
` desc "The AI coding agent built for the terminal."`,
136+
` homepage "https://github.com/sst/opencode"`,
137+
` version "${Script.version.split("-")[0]}"`,
138+
"",
139+
` depends_on "ripgrep"`,
140+
"",
141+
" on_macos do",
142+
" if Hardware::CPU.intel?",
143+
` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-darwin-x64.zip"`,
144+
` sha256 "${macX64Sha}"`,
145+
"",
146+
" def install",
147+
' bin.install "opencode"',
148+
" end",
149+
" end",
150+
" if Hardware::CPU.arm?",
151+
` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-darwin-arm64.zip"`,
152+
` sha256 "${macArm64Sha}"`,
153+
"",
154+
" def install",
155+
' bin.install "opencode"',
156+
" end",
157+
" end",
158+
" end",
159+
"",
160+
" on_linux do",
161+
" if Hardware::CPU.intel? and Hardware::CPU.is_64_bit?",
162+
` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-linux-x64.tar.gz"`,
163+
` sha256 "${x64Sha}"`,
164+
" def install",
165+
' bin.install "opencode"',
166+
" end",
167+
" end",
168+
" if Hardware::CPU.arm? and Hardware::CPU.is_64_bit?",
169+
` url "https://github.com/sst/opencode/releases/download/v${Script.version}/opencode-linux-arm64.tar.gz"`,
170+
` sha256 "${arm64Sha}"`,
171+
" def install",
172+
' bin.install "opencode"',
173+
" end",
174+
" end",
175+
" end",
176+
"end",
177+
"",
178+
"",
179+
].join("\n")
180+
181+
await $`rm -rf ./dist/homebrew-tap`
182+
await $`git clone https://${process.env["GITHUB_TOKEN"]}@github.com/sst/homebrew-tap.git ./dist/homebrew-tap`
183+
await Bun.file("./dist/homebrew-tap/opencode.rb").write(homebrewFormula)
184+
await $`cd ./dist/homebrew-tap && git add opencode.rb`
185+
await $`cd ./dist/homebrew-tap && git commit -m "Update to v${Script.version}"`
186+
await $`cd ./dist/homebrew-tap && git push`
187+
}

0 commit comments

Comments
 (0)