diff options
| -rwxr-xr-x | script/changelog.ts | 30 | ||||
| -rwxr-xr-x | script/publish.ts | 6 | ||||
| -rwxr-xr-x | script/version.ts | 7 |
3 files changed, 29 insertions, 14 deletions
diff --git a/script/changelog.ts b/script/changelog.ts index ace579ee4..0c8d65ba1 100755 --- a/script/changelog.ts +++ b/script/changelog.ts @@ -18,13 +18,29 @@ export const team = [ "R44VC0RP", ] -export async function getLatestRelease() { - return fetch("https://api.github.com/repos/anomalyco/opencode/releases/latest") - .then((res) => { - if (!res.ok) throw new Error(res.statusText) - return res.json() - }) - .then((data: any) => data.tag_name.replace(/^v/, "")) +type Release = { + tag_name: string + draft: boolean + prerelease: boolean +} + +export async function getLatestRelease(skip?: string) { + const data = await fetch("https://api.github.com/repos/anomalyco/opencode/releases?per_page=100").then((res) => { + if (!res.ok) throw new Error(res.statusText) + return res.json() + }) + + const releases = data as Release[] + const target = skip?.replace(/^v/, "") + + for (const release of releases) { + if (release.draft) continue + const tag = release.tag_name.replace(/^v/, "") + if (target && tag === target) continue + return tag + } + + throw new Error("No releases found") } type Commit = { diff --git a/script/publish.ts b/script/publish.ts index 5fa84825b..84abe6a66 100755 --- a/script/publish.ts +++ b/script/publish.ts @@ -2,7 +2,6 @@ import { $ } from "bun" import { Script } from "@opencode-ai/script" -import { buildNotes, getLatestRelease } from "./changelog" const highlightsTemplate = ` <!-- @@ -58,17 +57,12 @@ await $`bun install` await import(`../packages/sdk/js/script/build.ts`) if (Script.release) { - // notes.unshift(highlightsTemplate) await $`git commit -am "release: v${Script.version}"` await $`git tag v${Script.version}` await $`git fetch origin` await $`git cherry-pick HEAD..origin/dev`.nothrow() await $`git push origin HEAD --tags --no-verify --force-with-lease` await new Promise((resolve) => setTimeout(resolve, 5_000)) - const previous = await getLatestRelease() - console.log("previous", previous) - const notes = await buildNotes(previous, "dev") - await $`gh release edit v${Script.version} --draft=false --title "v${Script.version}" --notes ${notes.join("\n") || "No notable changes"}` } console.log("\n=== cli ===\n") diff --git a/script/version.ts b/script/version.ts index 861417f75..723677b8c 100755 --- a/script/version.ts +++ b/script/version.ts @@ -2,12 +2,17 @@ import { Script } from "@opencode-ai/script" import { $ } from "bun" +import { buildNotes, getLatestRelease } from "./changelog" -let output = [`version=${Script.version}`] +const output = [`version=${Script.version}`] if (!Script.preview) { await $`gh release create v${Script.version} -d --title "v${Script.version}" ${Script.preview ? "--prerelease" : ""}` const release = await $`gh release view v${Script.version} --json id,tagName`.json() + const previous = await getLatestRelease(Script.version) + const notes = await buildNotes(previous, "HEAD") + const body = notes.join("\n") || "No notable changes" + await $`gh release edit v${Script.version} --draft=false --title "v${Script.version}" --notes ${body}` output.push(`release=${release.id}`) output.push(`tag=${release.tagName}`) } |
