diff --git a/.github/release/publish-github-release.sh b/.github/release/publish-github-release.sh index f57963dd448..58210cac550 100755 --- a/.github/release/publish-github-release.sh +++ b/.github/release/publish-github-release.sh @@ -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 diff --git a/packages/desktop/script/pack.ts b/packages/desktop/script/pack.ts index ad4767c4def..0950d953044 100644 --- a/packages/desktop/script/pack.ts +++ b/packages/desktop/script/pack.ts @@ -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: @@ -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", + ) }