fes.js/.github/workflows/release-notes.mjs

24 lines
610 B
JavaScript
Raw Normal View History

2022-08-15 15:30:24 +08:00
#!/usr/bin/env node
import { readFileSync, writeFileSync } from "fs";
const tag = process.argv[2].replace("v", "");
const log = readFileSync("./CHANGELOG.md", { encoding: "utf-8" }).split("\n");
let result = "";
let inScope = false;
const regex = new RegExp(`^#+ \\[${tag}`);
for (let i = 0; i < log.length; i++) {
if (regex.test(log[i])) {
inScope = true;
result += log[i];
continue;
}
if (inScope && /^#+ \[/.test(log[i])) {
inScope = false;
break;
}
if(inScope){
result += `\n${log[i]}`;
}
}
writeFileSync(`notes-v${tag}.md`, result)