diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e91d38b6acc..fd0f5b64c1e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 }} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000000..4aad13af4f3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog + +Release notes for OpenCode V2, newest first. diff --git a/script/publish.ts b/script/publish.ts index 006c699566b..096134a594c 100755 --- a/script/publish.ts +++ b/script/publish.ts @@ -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]`}`