From 840a28a3f7a420c56d53b8bc3235ee432a629fe4 Mon Sep 17 00:00:00 2001 From: smakosh Date: Thu, 15 Oct 2026 10:55:29 +0200 Subject: [PATCH] fix(release): create the GitHub release before uploading assets - script/version.ts creates the draft release v that build-cli uploads archives to - script/publish.ts publishes the draft once npm and the tag are out - the v2 sync dropped both steps, so the v2.0.29 run failed with 'release not found' --- script/publish.ts | 4 ++++ script/version.ts | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) 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}`)