mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 16:13:12 +09:00
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:
1 parent
8692ea3941
commit
8e01a96df9
5 files changed
+173
-72
No files matched your search
+32
-20
@@ -258,7 +258,7 @@ async function fetchStatistics(lastRelease: Release, pullRequests: Issue[]): Pro
|
||||
};
|
||||
}
|
||||
|
||||
function printMarkdown(
|
||||
function formatMarkdown(
|
||||
changelog: Changelog,
|
||||
issues: Issue[],
|
||||
users: Issue["user"][],
|
||||
@@ -266,12 +266,13 @@ function printMarkdown(
|
||||
refText: (issue: Issue) => string,
|
||||
userText: (user: Issue["user"]) => string,
|
||||
) {
|
||||
const lines: string[] = [];
|
||||
const sections = new Set([...changelogSections, ...Object.keys(changelog)]);
|
||||
for (const section of sections) {
|
||||
if (section in changelog) {
|
||||
console.log(`### ${section}\n`);
|
||||
lines.push(`### ${section}`, "");
|
||||
const entries = changelog[section];
|
||||
console.log(entries.map(text => (
|
||||
lines.push(...entries.map(text => (
|
||||
`- ${text.replaceAll(/#(\d+)/g, (ref, idAsText) => {
|
||||
const id = Number.parseInt(idAsText, 10);
|
||||
if (!Number.isFinite(id)) {
|
||||
@@ -283,27 +284,29 @@ function printMarkdown(
|
||||
}
|
||||
return refText(issue);
|
||||
})}`
|
||||
)).join("\n"));
|
||||
console.log();
|
||||
)));
|
||||
lines.push("");
|
||||
}
|
||||
}
|
||||
|
||||
console.log("### Contributors\n");
|
||||
console.log(`Many thanks to the following for contributing to this release:`);
|
||||
console.log(users.map(userText).join(", "));
|
||||
lines.push("### Contributors", "");
|
||||
lines.push("Many thanks to the following for contributing to this release:");
|
||||
lines.push(users.map(userText).join(", "));
|
||||
|
||||
const format = (value: number) => value.toLocaleString("en-US");
|
||||
console.log("\n### Statistics\n");
|
||||
console.log([
|
||||
lines.push("", "### Statistics", "");
|
||||
lines.push([
|
||||
`Commits: ${format(statistics.commits)}`,
|
||||
`Pull Requests: ${format(statistics.pullRequests)}`,
|
||||
`Files Changed: ${format(statistics.filesChanged)}`,
|
||||
`Additions: +${format(statistics.lineAdditions)}`,
|
||||
`Deletions: -${format(statistics.lineDeletions)}`,
|
||||
].join(" "));
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
async function main() {
|
||||
/** Builds the release notes for the changes merged since the last release. */
|
||||
export async function generateReleaseNotes() {
|
||||
const lastRelease = await fetchLastRelease();
|
||||
const issues = await fetchIssuesUpdatedSince(lastRelease.created_at);
|
||||
|
||||
@@ -314,22 +317,31 @@ async function main() {
|
||||
));
|
||||
|
||||
const changelog = changelogFromPullRequests(pullRequests, issues);
|
||||
const users = [...new Map(pullRequests.map(issue => [issue.user.login, issue.user])).values()]
|
||||
const users = [...new Map(pullRequests.map(issue => [issue.user.login, issue.user])).values()];
|
||||
const statistics = await fetchStatistics(lastRelease, pullRequests);
|
||||
|
||||
return {
|
||||
github: formatMarkdown(changelog, issues, users, statistics,
|
||||
issue => `${repository}#${issue.number}`,
|
||||
user => `@${user.login}`,
|
||||
),
|
||||
changelog: formatMarkdown(changelog, issues, users, statistics,
|
||||
issue => `[#${issue.number}](<${issue.html_url}>)`,
|
||||
user => `[@${user.login}](<${user.html_url}>)`
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const notes = await generateReleaseNotes();
|
||||
|
||||
console.log();
|
||||
console.log("=== Github Release Markdown ===");
|
||||
printMarkdown(changelog, issues, users, statistics,
|
||||
issue => `${repository}#${issue.number}`,
|
||||
user => `@${user.login}`,
|
||||
);
|
||||
console.log(notes.github);
|
||||
|
||||
console.log();
|
||||
console.log("=== Discord / Changelog Markdown ===");
|
||||
printMarkdown(changelog, issues, users, statistics,
|
||||
issue => `[#${issue.number}](<${issue.html_url}>)`,
|
||||
user => `[@${user.login}](<${user.html_url}>)`
|
||||
);
|
||||
console.log(notes.changelog);
|
||||
}
|
||||
|
||||
if (import.meta.main) {
|
||||
|
||||
Reference in new issue
Block a user