mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-16 13:05:14 +03:00
feat(release): write reviewed V2 release notes to CHANGELOG.md (#53964)
This commit is contained in:
@@ -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 }}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# Changelog
|
||||
|
||||
Release notes for OpenCode V2, newest first.
|
||||
@@ -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]`}`
|
||||
|
||||
Reference in New Issue
Block a user