Skip to content

Commit ce17f9d

Browse files
authored
desktop: publish betas to separate repo (anomalyco#14376)
1 parent 92ab421 commit ce17f9d

File tree

7 files changed

+105
-39
lines changed

7 files changed

+105
-39
lines changed

.github/workflows/publish.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ jobs:
4141

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

44+
- name: Setup git committer
45+
id: committer
46+
uses: ./.github/actions/setup-git-committer
47+
with:
48+
opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
49+
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
50+
4451
- name: Install OpenCode
4552
if: inputs.bump || inputs.version
4653
run: bun i -g opencode-ai
@@ -49,14 +56,16 @@ jobs:
4956
run: |
5057
./script/version.ts
5158
env:
52-
GH_TOKEN: ${{ github.token }}
59+
GH_TOKEN: ${{ steps.committer.outputs.token }}
5360
OPENCODE_BUMP: ${{ inputs.bump }}
5461
OPENCODE_VERSION: ${{ inputs.version }}
5562
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
63+
GH_REPO: ${{ (github.ref_name == 'beta' && 'anomalyco/opencode-beta') || github.repository }}
5664
outputs:
5765
version: ${{ steps.version.outputs.version }}
5866
release: ${{ steps.version.outputs.release }}
5967
tag: ${{ steps.version.outputs.tag }}
68+
repo: ${{ steps.version.outputs.repo }}
6069

6170
build-cli:
6271
needs: version
@@ -69,14 +78,22 @@ jobs:
6978

7079
- uses: ./.github/actions/setup-bun
7180

81+
- name: Setup git committer
82+
id: committer
83+
uses: ./.github/actions/setup-git-committer
84+
with:
85+
opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
86+
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
87+
7288
- name: Build
7389
id: build
7490
run: |
7591
./packages/opencode/script/build.ts
7692
env:
7793
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
7894
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
79-
GH_TOKEN: ${{ github.token }}
95+
GH_REPO: ${{ needs.version.outputs.repo }}
96+
GH_TOKEN: ${{ steps.committer.outputs.token }}
8097

8198
- uses: actions/upload-artifact@v4
8299
with:
@@ -189,21 +206,30 @@ jobs:
189206
if: contains(matrix.settings.host, 'ubuntu')
190207
run: cargo tauri --version
191208

209+
- name: Setup git committer
210+
id: committer
211+
uses: ./.github/actions/setup-git-committer
212+
with:
213+
opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
214+
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
215+
192216
- name: Build and upload artifacts
193217
uses: tauri-apps/tauri-action@390cbe447412ced1303d35abe75287949e43437a
194218
timeout-minutes: 60
195219
with:
196220
projectPath: packages/desktop
197221
uploadWorkflowArtifacts: true
198222
tauriScript: ${{ (contains(matrix.settings.host, 'ubuntu') && 'cargo tauri') || '' }}
199-
args: --target ${{ matrix.settings.target }} --config ./src-tauri/tauri.prod.conf.json --verbose
223+
args: --target ${{ matrix.settings.target }} --config ${{ (github.ref_name == 'beta' && './src-tauri/tauri.beta.conf.json') || './src-tauri/tauri.prod.conf.json' }} --verbose
200224
updaterJsonPreferNsis: true
201225
releaseId: ${{ needs.version.outputs.release }}
202226
tagName: ${{ needs.version.outputs.tag }}
203227
releaseDraft: true
204228
releaseAssetNamePattern: opencode-desktop-[platform]-[arch][ext]
229+
repo: ${{ (github.ref_name == 'beta' && 'opencode-beta') || '' }}
230+
releaseCommitish: ${{ github.sha }}
205231
env:
206-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
232+
GITHUB_TOKEN: ${{ steps.committer.outputs.token }}
207233
TAURI_BUNDLER_NEW_APPIMAGE_FORMAT: true
208234
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
209235
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
@@ -280,4 +306,5 @@ jobs:
280306
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
281307
AUR_KEY: ${{ secrets.AUR_KEY }}
282308
GITHUB_TOKEN: ${{ steps.committer.outputs.token }}
309+
GH_REPO: ${{ needs.version.outputs.repo }}
283310
NPM_CONFIG_PROVENANCE: false

packages/console/app/src/routes/download/[platform].ts renamed to packages/console/app/src/routes/download/[channel]/[platform].ts

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { APIEvent } from "@solidjs/start"
2-
import { DownloadPlatform } from "./types"
1+
import type { APIEvent } from "@solidjs/start"
2+
import type { DownloadPlatform } from "../types"
33

44
const assetNames: Record<string, string> = {
55
"darwin-aarch64-dmg": "opencode-desktop-darwin-aarch64.dmg",
@@ -17,17 +17,20 @@ const downloadNames: Record<string, string> = {
1717
"windows-x64-nsis": "OpenCode Desktop Installer.exe",
1818
} satisfies { [K in DownloadPlatform]?: string }
1919

20-
export async function GET({ params: { platform } }: APIEvent) {
20+
export async function GET({ params: { platform, channel } }: APIEvent) {
2121
const assetName = assetNames[platform]
2222
if (!assetName) return new Response("Not Found", { status: 404 })
2323

24-
const resp = await fetch(`https://github.com/anomalyco/opencode/releases/latest/download/${assetName}`, {
25-
cf: {
26-
// in case gh releases has rate limits
27-
cacheTtl: 60 * 5,
28-
cacheEverything: true,
29-
},
30-
} as any)
24+
const resp = await fetch(
25+
`https://github.com/anomalyco/${channel === "stable" ? "opencode" : "opencode-beta"}/releases/latest/download/${assetName}`,
26+
{
27+
cf: {
28+
// in case gh releases has rate limits
29+
cacheTtl: 60 * 5,
30+
cacheEverything: true,
31+
},
32+
} as any,
33+
)
3134

3235
const downloadName = downloadNames[platform]
3336

packages/console/app/src/routes/download/index.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import "./index.css"
2-
import { Title, Meta } from "@solidjs/meta"
3-
import { A, createAsync, query } from "@solidjs/router"
4-
import { Header } from "~/component/header"
5-
import { Footer } from "~/component/footer"
6-
import { IconCopy, IconCheck } from "~/component/icon"
2+
import { Meta, Title } from "@solidjs/meta"
3+
import { A } from "@solidjs/router"
4+
import { createSignal, type JSX, onMount, Show } from "solid-js"
75
import { Faq } from "~/component/faq"
8-
import desktopAppIcon from "../../asset/lander/opencode-desktop-icon.png"
6+
import { Footer } from "~/component/footer"
7+
import { Header } from "~/component/header"
8+
import { IconCheck, IconCopy } from "~/component/icon"
99
import { Legal } from "~/component/legal"
10+
import { LocaleLinks } from "~/component/locale-links"
1011
import { config } from "~/config"
11-
import { createSignal, onMount, Show, JSX } from "solid-js"
12-
import { DownloadPlatform } from "./types"
1312
import { useI18n } from "~/context/i18n"
1413
import { useLanguage } from "~/context/language"
15-
import { LocaleLinks } from "~/component/locale-links"
14+
import desktopAppIcon from "../../asset/lander/opencode-desktop-icon.png"
15+
import type { DownloadPlatform } from "./types"
1616

1717
type OS = "macOS" | "Windows" | "Linux" | null
1818

@@ -40,8 +40,8 @@ function getDownloadPlatform(os: OS): DownloadPlatform {
4040
}
4141
}
4242

43-
function getDownloadHref(platform: DownloadPlatform) {
44-
return `/download/${platform}`
43+
function getDownloadHref(platform: DownloadPlatform, channel: "stable" | "beta" = "stable") {
44+
return `/download/${channel}/${platform}`
4545
}
4646

4747
function IconDownload(props: JSX.SvgSVGAttributes<SVGSVGElement>) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"$schema": "https://schema.tauri.app/config/2",
3+
"productName": "OpenCode Beta",
4+
"identifier": "ai.opencode.desktop.beta",
5+
"bundle": {
6+
"createUpdaterArtifacts": true,
7+
"linux": {
8+
"rpm": {
9+
"compression": {
10+
"type": "none"
11+
}
12+
}
13+
}
14+
},
15+
"plugins": {
16+
"updater": {
17+
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IEYwMDM5Nzg5OUMzOUExMDQKUldRRW9UbWNpWmNEOENYT01CV0lhOXR1UFhpaXJsK1Z3aU9lZnNtNzE0TDROWVMwVW9XQnFOelkK",
18+
"endpoints": ["https://github.com/anomalyco/opencode-beta/releases/latest/download/latest.json"]
19+
}
20+
}
21+
}

packages/opencode/script/build.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
#!/usr/bin/env bun
22

3-
import solidPlugin from "../node_modules/@opentui/solid/scripts/solid-plugin"
4-
import path from "path"
5-
import fs from "fs"
63
import { $ } from "bun"
4+
import fs from "fs"
5+
import path from "path"
76
import { fileURLToPath } from "url"
7+
import solidPlugin from "../node_modules/@opentui/solid/scripts/solid-plugin"
88

99
const __filename = fileURLToPath(import.meta.url)
1010
const __dirname = path.dirname(__filename)
1111
const dir = path.resolve(__dirname, "..")
1212

1313
process.chdir(dir)
1414

15-
import pkg from "../package.json"
1615
import { Script } from "@opencode-ai/script"
16+
import pkg from "../package.json"
17+
1718
const modelsUrl = process.env.OPENCODE_MODELS_URL || "https://models.dev"
1819
// Fetch and generate models.dev snapshot
1920
const modelsData = process.env.MODELS_DEV_API_JSON
@@ -26,7 +27,11 @@ await Bun.write(
2627
console.log("Generated models-snapshot.ts")
2728

2829
// Load migrations from migration directories
29-
const migrationDirs = (await fs.promises.readdir(path.join(dir, "migration"), { withFileTypes: true }))
30+
const migrationDirs = (
31+
await fs.promises.readdir(path.join(dir, "migration"), {
32+
withFileTypes: true,
33+
})
34+
)
3035
.filter((entry) => entry.isDirectory() && /^\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}/.test(entry.name))
3136
.map((entry) => entry.name)
3237
.sort()
@@ -171,7 +176,6 @@ for (const item of targets) {
171176
compile: {
172177
autoloadBunfig: false,
173178
autoloadDotenv: false,
174-
//@ts-ignore (bun types aren't up to date)
175179
autoloadTsconfig: true,
176180
autoloadPackageJson: true,
177181
target: name.replace(pkg.name, "bun") as any,
@@ -214,7 +218,7 @@ if (Script.release) {
214218
await $`zip -r ../../${key}.zip *`.cwd(`dist/${key}/bin`)
215219
}
216220
}
217-
await $`gh release upload v${Script.version} ./dist/*.zip ./dist/*.tar.gz --clobber`
221+
await $`gh release upload v${Script.version} ./dist/*.zip ./dist/*.tar.gz --clobber --repo ${process.env.GH_REPO}`
218222
}
219223

220224
export { binaries }

script/publish.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,16 @@ await $`bun install`
5757
await import(`../packages/sdk/js/script/build.ts`)
5858

5959
if (Script.release) {
60-
await $`git commit -am "release: v${Script.version}"`
61-
await $`git tag v${Script.version}`
62-
await $`git fetch origin`
63-
await $`git cherry-pick HEAD..origin/dev`.nothrow()
64-
await $`git push origin HEAD --tags --no-verify --force-with-lease`
65-
await new Promise((resolve) => setTimeout(resolve, 5_000))
66-
await $`gh release edit v${Script.version} --draft=false`
60+
if (!Script.preview) {
61+
await $`git commit -am "release: v${Script.version}"`
62+
await $`git tag v${Script.version}`
63+
await $`git fetch origin`
64+
await $`git cherry-pick HEAD..origin/dev`.nothrow()
65+
await $`git push origin HEAD --tags --no-verify --force-with-lease`
66+
await new Promise((resolve) => setTimeout(resolve, 5_000))
67+
}
68+
69+
await $`gh release edit v${Script.version} --draft=false --repo ${process.env.GH_REPO}`
6770
}
6871

6972
console.log("\n=== cli ===\n")

script/version.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,16 @@ if (!Script.preview) {
1717
const release = await $`gh release view v${Script.version} --json tagName,databaseId`.json()
1818
output.push(`release=${release.databaseId}`)
1919
output.push(`tag=${release.tagName}`)
20+
} else if (Script.channel === "beta") {
21+
await $`gh release create v${Script.version} -d --title "v${Script.version}" --repo ${process.env.GH_REPO}`
22+
const release =
23+
await $`gh release view v${Script.version} --json tagName,databaseId --repo ${process.env.GH_REPO}`.json()
24+
output.push(`release=${release.databaseId}`)
25+
output.push(`tag=${release.tagName}`)
2026
}
2127

28+
output.push(`repo=${process.env.GH_REPO}`)
29+
2230
if (process.env.GITHUB_OUTPUT) {
2331
await Bun.write(process.env.GITHUB_OUTPUT, output.join("\n"))
2432
}

0 commit comments

Comments
 (0)