Add a prepare release script

scripts/prepare_release.mts takes a version, sets it in the package.json
files under packages/ and plugins/, adds the pr_to_changelog.mts output to
the top of CHANGELOG.md, then commits "Prepare <version>" and tags it
v<version>. It does not push.

pr_to_changelog.mts now exports generateReleaseNotes() so the output can
be reused. The template comment in CHANGELOG.md is removed so the first
"## " heading is always the latest release.

Closes #1240

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bbassieandClaude Opus 5.5 committed 2026-11-21 02:28:33 +00:00
1 parent 8692ea3941
commit 8e01a96df9
5 files changed
+173 -72

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
import assert from "node:assert/strict";
import { addChangelogEntry, setPackageVersion } from "../scripts/prepare_release.mts";
describe("scripts/prepare_release", function() {
describe("setPackageVersion()", function() {
it("replaces only the package version", function() {
const text = (version) => `${JSON.stringify({
name: "@clusterio/lib",
version,
dependencies: { a: "2.1.1" },
}, null, "\t")}\n`;
assert.equal(setPackageVersion(text("2.1.1"), "2.2.0"), text("2.2.0"));
});
it("throws if there is no version", function() {
assert.throws(() => setPackageVersion('{\n\t"name": "x"\n}\n', "2.2.0"), /No version field/);
});
});
describe("addChangelogEntry()", function() {
const changelog = "# Changelog\n\n## Version 2.1.1\n\n### Fixes\n\n- Old fix.\n";
it("adds the entry above the previous release", function() {
assert.equal(
addChangelogEntry(changelog, "2.1.2", "### Fixes\n\n- New fix.\n"),
"# Changelog\n\n## Version 2.1.2\n\n### Fixes\n\n- New fix.\n\n\n" +
"## Version 2.1.1\n\n### Fixes\n\n- Old fix.\n",
);
});
it("throws if the version already has an entry", function() {
assert.throws(() => addChangelogEntry(changelog, "2.1.1", "- Fix."), /already has an entry/);
});
});
});