Repository navigation
chore: add a release notes script and the release steps to AGENTS.md #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+62
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| // Prints the change list of a release as Markdown: the squash-merged pull | ||
| // requests since the last tag, grouped by Conventional Commit type, up to the | ||
| // next tag, or before it is made, its version bump commit. Without a next tag, | ||
| // up to HEAD. Write a few sentences for users above it. | ||
| // | ||
| // node scripts/release-notes.ts [<since-tag> [<next-tag>]] (since: the newest tag before HEAD) | ||
|
|
||
| import { execFileSync } from "node:child_process"; | ||
|
|
||
| const REPO = "https://github.com/Project516/java-web"; | ||
| const git = (...args: string[]) => execFileSync("git", args, { encoding: "utf8" }).trim(); | ||
|
|
||
| const since = process.argv[2] ?? git("describe", "--tags", "--abbrev=0"); | ||
|
project516-review-bot[bot] marked this conversation as resolved.
Resolved
|
||
| const next = process.argv[3]; | ||
| function endOf(next: string): string { | ||
| if (git("tag", "--list", next) === next) return next; | ||
| const title = `chore: release ${next.replace(/^v/, "")}`; | ||
| const bump = git("log", "--first-parent", "--format=%H %s", `${since}..HEAD`).split("\n").find((l) => { | ||
| const subject = l.slice(l.indexOf(" ") + 1); | ||
| return subject === title || (subject.startsWith(title + " (#") && /^ \(#\d+\)$/.test(subject.slice(title.length))); | ||
| }); | ||
| if (!bump) { | ||
| console.error(`no tag ${next} and no "chore: release" commit for it since ${since}`); | ||
| process.exit(1); | ||
| } | ||
| return bump.slice(0, bump.indexOf(" ")); | ||
| } | ||
| const end = next ? endOf(next) : git("rev-parse", "HEAD"); | ||
| const titles = git("log", "--first-parent", "--format=%s", `${since}..${end}`).split("\n").filter(Boolean); | ||
|
|
||
| interface Entry { type?: string; scope?: string; breaking?: boolean; summary: string; pr?: string } | ||
| const sections: [string, (e: Entry) => boolean][] = [ | ||
| ["Breaking changes", (e) => !!e.breaking], | ||
| ["Features", (e) => e.type === "feat"], | ||
| ["Performance", (e) => e.type === "perf"], | ||
| ["Fixes", (e) => e.type === "fix"], | ||
| ["Dependencies", (e) => e.scope === "deps"], | ||
| ["Build and CI", (e) => e.type === "build" || e.type === "ci"], | ||
| ["Documentation", (e) => e.type === "docs"], | ||
| ["Other", () => true], | ||
| ]; | ||
|
|
||
| const groups = new Map<string, string[]>(sections.map(([name]) => [name, []])); | ||
| for (const title of titles) { | ||
| // the version bump is the release itself | ||
| if (/^chore: release \S+( \(#\d+\))?$/.test(title)) continue; | ||
|
project516-review-bot[bot] marked this conversation as resolved.
Resolved
|
||
| const m = /^(\w+)(?:\(([^)]+)\))?(!)?: (.*?)(?: \(#(\d+)\))?$/.exec(title); | ||
| const e: Entry = m ? { type: m[1], scope: m[2], breaking: !!m[3], summary: m[4], pr: m[5] } : { summary: title }; | ||
| const [name] = sections.find(([, matches]) => matches(e))!; | ||
| const scope = e.scope && e.scope !== "deps" ? `**${e.scope}:** ` : ""; | ||
| groups.get(name)!.push(`- ${scope}${e.summary}${e.pr ? ` ([#${e.pr}](${REPO}/pull/${e.pr}))` : ""}`); | ||
| } | ||
|
|
||
| const out: string[] = []; | ||
| for (const [name, lines] of groups) if (lines.length) out.push(`## ${name}\n\n${lines.join("\n")}\n`); | ||
| out.push(`**Full list:** ${REPO}/compare/${since}...${next ?? end}`); | ||
| console.log(out.join("\n")); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.