feat: Enhance version bumping process to update CHANGELOG.md with new version header

This commit is contained in:
Jiaxin Peng
2026-03-04 09:30:32 +00:00
parent cd7eb78378
commit 6b02cb219e
2 changed files with 38 additions and 1 deletions

View File

@@ -12,3 +12,40 @@ writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t"));
let versions = JSON.parse(readFileSync("versions.json", "utf8"));
versions[targetVersion] = minAppVersion;
writeFileSync("versions.json", JSON.stringify(versions, null, "\t"));
// tag the changelog by converting "Unreleased" to the new version section
function bumpChangelog(version) {
const changelogPath = "CHANGELOG.md";
const content = readFileSync(changelogPath, "utf8");
const unreleasedHeader = "## Unreleased";
if (!content.includes(unreleasedHeader)) {
console.warn(`[version-bump] ${unreleasedHeader} not found in ${changelogPath}, skipping changelog tagging`);
return;
}
const today = new Date().toISOString().slice(0, 10);
const releaseHeader = `## v${version} (${today})`;
const updated = content.replace(unreleasedHeader, releaseHeader);
const marker = "# Changelog\n\n";
if (!updated.startsWith(marker)) {
writeFileSync(changelogPath, updated);
return;
}
const newUnreleased = [
"## Unreleased",
"",
"### Added",
"",
"### Changed",
"",
"### Fixed",
"",
].join("\n");
writeFileSync(changelogPath, marker + newUnreleased + updated.slice(marker.length));
}
bumpChangelog(targetVersion);