diff --git a/script/publish.ts b/script/publish.ts index c2cf0f42..b1e20bc0 100755 --- a/script/publish.ts +++ b/script/publish.ts @@ -71,3 +71,7 @@ if (Script.release && !Script.preview) { await $`git push origin HEAD:${syncBranch} --no-verify` } } + +if (Script.release) { + await $`gh release edit ${tag} --draft=false --repo ${process.env.GH_REPO}` +} diff --git a/script/version.ts b/script/version.ts index f9e950d8..a043de15 100755 --- a/script/version.ts +++ b/script/version.ts @@ -1,12 +1,21 @@ #!/usr/bin/env bun import { Script } from "@opencode/script" +import { $ } from "bun" const output = [`version=${Script.version}`] if (!Script.preview || Script.channel === "beta") { + const tag = `v${Script.version}` + const repo = process.env.GH_REPO + // build-cli uploads the release archives to this draft, and script/publish.ts publishes it. + const existing = await $`gh release view ${tag} --repo ${repo} --json tagName`.quiet().nothrow() + if (existing.exitCode !== 0) { + const target = process.env.GITHUB_SHA ?? (await $`git rev-parse HEAD`.text()).trim() + await $`gh release create ${tag} --draft --target ${target} --title ${tag} --generate-notes --repo ${repo}` + } output.push("release=true") - output.push(`tag=v${Script.version}`) + output.push(`tag=${tag}`) } output.push(`repo=${process.env.GH_REPO}`)