mirror of
https://github.com/jxpeng98/obsidian-to-NotionNext
synced 2026-07-29 08:08:34 +08:00
feat: Enhance version bumping process to update CHANGELOG.md with new version header
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "node esbuild.config.mjs",
|
"dev": "node esbuild.config.mjs",
|
||||||
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
|
||||||
"version": "node version-bump.mjs && git add manifest.json versions.json"
|
"version": "node version-bump.mjs && git add manifest.json versions.json CHANGELOG.md"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "Jiaxin PENG",
|
"author": "Jiaxin PENG",
|
||||||
|
|||||||
@@ -12,3 +12,40 @@ writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t"));
|
|||||||
let versions = JSON.parse(readFileSync("versions.json", "utf8"));
|
let versions = JSON.parse(readFileSync("versions.json", "utf8"));
|
||||||
versions[targetVersion] = minAppVersion;
|
versions[targetVersion] = minAppVersion;
|
||||||
writeFileSync("versions.json", JSON.stringify(versions, null, "\t"));
|
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);
|
||||||
|
|||||||
Reference in New Issue
Block a user