feat(release): write reviewed V2 release notes to CHANGELOG.md (#53964)

This commit is contained in:
Dax
2026-10-08 09:59:45 -04:00
committed by GitHub
parent 6dfb413917
commit d44561558f
3 changed files with 20 additions and 1 deletions
+15
View File
@@ -27,6 +27,20 @@ async function prepareReleaseFiles() {
await $`bun install`
}
async function writeChangelog() {
const notes = process.env["OPENCODE_RELEASE_NOTES"]?.trim()
if (!notes) return
const file = Bun.file("CHANGELOG.md")
const text = await file.text()
const lines = text.split("\n")
if (lines.some((line) => line === `## ${tag}` || line.startsWith(`## ${tag} `))) return
const index = lines.findIndex((line) => line.startsWith("## "))
const head = (index === -1 ? lines : lines.slice(0, index)).join("\n").trimEnd()
const rest = index === -1 ? "" : lines.slice(index).join("\n")
const entry = `## ${tag} — ${new Date().toISOString().slice(0, 10)}\n\n${notes}\n`
await file.write(`${head}\n\n${entry}${rest ? `\n${rest}` : ""}`)
}
if (Script.release && !Script.preview) {
await $`git fetch origin --tags`
await $`git switch --detach`
@@ -90,6 +104,7 @@ if (Script.release && !Script.preview) {
await $`git fetch origin`
await $`git checkout -B v2 origin/v2`
await prepareReleaseFiles()
await writeChangelog()
if ((await $`git diff --quiet`.nothrow()).exitCode !== 0) {
// The release already published this code; a push-triggered dev publish of a version bump is wasted work.
await $`git commit -am ${`sync release versions for ${tag} [skip ci]`}`