Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/release/publish-github-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ printf '%s\n' "${OPENCODE_RELEASE_NOTES:-}" > "$assets.md"
if dry_run; then exit 0; fi

tag="v$OPENCODE_VERSION"
gh release view "$tag" > /dev/null 2>&1 || gh release create "$tag" --draft --verify-tag --title "$tag" --notes-file "$assets.md"
# OpenCode 1 update paths (CLI upgrade, electron-updater, Scoop) follow GitHub's Latest release, which must stay on 1.x.
gh release view "$tag" > /dev/null 2>&1 ||
gh release create "$tag" --draft --verify-tag --latest=false --title "$tag" --notes-file "$assets.md"
gh release upload "$tag" "$assets"/* --clobber
gh release edit "$tag" --draft=false
gh release edit "$tag" --draft=false --latest=false
24 changes: 21 additions & 3 deletions packages/desktop/script/pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { $ } from "bun"
import { cp, mkdir, readdir, rm } from "node:fs/promises"
import path from "node:path"
import { getConfig } from "../electron-builder.config"
import { getCurrentCli, resolveChannel } from "./utils"

// Packages the built app (out/) for OPENCODE_TARGET into dist/desktop at the repository root, unsigned:
Expand Down Expand Up @@ -50,12 +51,29 @@ if (!app && os === "mac") {
const bundles = (await readdir(parent)).filter((file) => file.endsWith(".app"))

if (bundles.length !== 1) throw new Error(`Expected one .app bundle in ${parent}, found ${bundles.join(", ")}`)
await writeUpdateConfig(path.join(parent, bundles[0], "Contents", "Resources"))
await $`tar -cf ${path.join(out, `opencode-desktop-mac-${cli.cpu}.app.tar`)} -C ${parent} ${bundles[0]}`
}

if (!app && os === "win") {
await $`bunx electron-builder ${flags} --dir`
await cp(path.join("dist", cli.cpu === "arm64" ? "win-arm64-unpacked" : "win-unpacked"), path.join(out, "app"), {
recursive: true,
})
const unpacked = path.join("dist", cli.cpu === "arm64" ? "win-arm64-unpacked" : "win-unpacked")
await writeUpdateConfig(path.join(unpacked, "resources"))
await cp(unpacked, path.join(out, "app"), { recursive: true })
}

// electron-builder writes resources/app-update.yml only for dmg, zip and nsis targets, not for --dir builds.
// electron-updater reads its feed from that file, so write the one those targets would.
async function writeUpdateConfig(resources: string) {
const publish = getConfig().publish
const name: string = (await Bun.file("package.json").json()).name
await Bun.write(
path.join(resources, "app-update.yml"),
[
`provider: ${publish.provider}`,
`url: ${publish.url}`,
`channel: ${publish.channel}`,
`updaterCacheDirName: '${name.replace(/[/\\:*?"<>|]/g, "").toLowerCase()}-updater'`,
].join("\n") + "\n",
)
}
Loading