Files
Kilo-Org_kilocode/script/version.ts
T
Mark IJbema e199c0e0fb feat: integrate changesets into existing publish.yml release flow
Remove standalone changeset-release.yml workflow (version bump PR approach).
Instead, run changeset version inside publish.yml's version job to consume
.changeset/*.md files into CHANGELOG.md, then extract the latest section
for GitHub release notes. This replaces the previous AI-generated changelog
(opencode run --command changelog) with changeset-based entries.
2026-04-13 17:18:22 +02:00

60 lines
2.4 KiB
TypeScript
Executable File

#!/usr/bin/env bun
import { Script } from "@opencode-ai/script"
import { $ } from "bun"
const output = [`version=${Script.version}`]
if (!Script.preview) {
// kilocode_change start - use changesets for changelog generation
// Run changeset version to consume .changeset/*.md files into CHANGELOG.md.
// This also bumps package.json versions, but publish.ts overwrites them with
// Script.version later, so the changeset-computed versions are irrelevant.
await $`bunx changeset version`.nothrow()
// Extract the latest version section from CHANGELOG.md for release notes
const changelog = await Bun.file(`${process.cwd()}/CHANGELOG.md`)
.text()
.catch(() => "")
const body = extractLatestSection(changelog) || "No notable changes"
const dir = process.env.RUNNER_TEMP ?? "/tmp"
const notesFile = `${dir}/opencode-release-notes.txt`
await Bun.write(notesFile, body)
// kilocode_change end
await $`gh release create v${Script.version} -d --title "v${Script.version}" --notes-file ${notesFile}`
const release = await $`gh release view v${Script.version} --json tagName,databaseId`.json()
output.push(`release=${release.databaseId}`)
output.push(`tag=${release.tagName}`)
// kilocode_change start - handle both beta and rc preview channels
} else if (Script.channel === "beta" || Script.channel === "rc") {
await $`gh release create v${Script.version} -d --prerelease --title "v${Script.version}" --repo ${process.env.GH_REPO}`
const release =
await $`gh release view v${Script.version} --json tagName,databaseId --repo ${process.env.GH_REPO}`.json()
output.push(`release=${release.databaseId}`)
output.push(`tag=${release.tagName}`)
// kilocode_change end
}
output.push(`repo=${process.env.GH_REPO}`)
if (process.env.GITHUB_OUTPUT) {
await Bun.write(process.env.GITHUB_OUTPUT, output.join("\n"))
}
// kilocode_change start - extract latest changelog section for release notes
function extractLatestSection(changelog: string): string {
if (!changelog) return ""
const lines = changelog.split("\n")
// Find first ## heading (version section)
const start = lines.findIndex((line) => /^## /.test(line))
if (start < 0) return ""
// Find the next ## heading after the first one
const end = lines.findIndex((line, i) => i > start && /^## /.test(line))
const section = lines.slice(start + 1, end < 0 ? undefined : end)
return section.join("\n").trim()
}
// kilocode_change end
process.exit(0)