fix(release): atomic update-channel publish

upload the payload first and latest.yml last, prune the previous version
only afterwards, reuse an existing release, add --channel-only; sync-
changelog uses a function replacement so $-sequences in notes survive
This commit is contained in:
Bill committed 2026-09-20 20:27:05 +08:00
1 parent c0342db1e8
commit 24f7e7c52a
2 files changed
+121 -26

No files matched your search

+3 -1
View File
@@ -52,8 +52,10 @@ const sync = ({ notes, changelog, header, required }) => {
}
const section = `## v${pkgVersion} - ${new Date().toISOString().slice(0, 10)}\n\n${body}\n`
// Function replacement, not a string: a notes body containing `$&`, `$1`, `` $` ``
// or `$'` would otherwise be expanded by String.replace and corrupt the merge.
const updated = existing
? existing.replace(new RegExp(`^(${header}\\n\\n)`), `$1${section}\n`)
? existing.replace(new RegExp(`^(${header}\\n\\n)`), (_m, head) => `${head}${section}\n`)
: `${header}\n\n${section}`
fs.writeFileSync(changelogPath, updated, 'utf8')
console.log(`${changelog}: added v${pkgVersion} (${body.split('\n').length} lines)`)