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
Unverified
parent 6dfb413917
commit d44561558f
3 changed files with 20 additions and 1 deletions
+2 -1
View File
@@ -25,7 +25,7 @@ on:
required: false
type: string
release_notes:
description: "Reviewed V2 release notes for the Discord announcement (optional)"
description: "Reviewed V2 release notes for CHANGELOG.md and the Discord announcement (optional)"
required: false
type: string
@@ -647,6 +647,7 @@ jobs:
env:
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
OPENCODE_RELEASE_NOTES: ${{ (github.ref_name == 'v2' && inputs.release_notes) || '' }}
AUR_KEY: ${{ secrets.AUR_KEY }}
GITHUB_TOKEN: ${{ steps.committer.outputs.token }}
GH_REPO: ${{ needs.version.outputs.repo }}
+3
View File
@@ -0,0 +1,3 @@
# Changelog
Release notes for OpenCode V2, newest first.
+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]`}`