23 lines
661 B
JavaScript
23 lines
661 B
JavaScript
#!/usr/bin/env node
|
|
// Print the CHANGELOG slice for a given tag to stdout.
|
|
// Used by the release workflow to attach release notes.
|
|
|
|
import { readFileSync } from "node:fs";
|
|
|
|
const tag = process.argv[2];
|
|
if (!tag) {
|
|
console.error("Usage: extract-release-notes.mjs vX.Y.Z");
|
|
process.exit(1);
|
|
}
|
|
|
|
const version = tag.replace(/^v/, "");
|
|
const changelog = readFileSync("CHANGELOG.md", "utf8");
|
|
const re = new RegExp(`## \\[${version.replace(/\./g, "\\.")}\\][\\s\\S]*?(?=\\n## \\[|$)`, "m");
|
|
const m = changelog.match(re);
|
|
|
|
if (!m) {
|
|
console.error(`No CHANGELOG section found for [${version}].`);
|
|
process.exit(1);
|
|
}
|
|
process.stdout.write(m[0].trim() + "\n");
|