mirror of
https://github.com/efiten/coredrive-rx.git
synced 2026-11-23 12:57:58 +00:00
AGENTS.md said every tag must carry a "What's New" body, cumulative, newest first. That rule was a human convention and it was missed on twelve tags in a row: v1.6.0 through v1.10.3 all shipped the CI-generated changelog link, so v1.5.0 was the last release anyone could read while region discovery, the airtime budget, the retry backoff, the FLOOD-reply warning and the AES padding fix all landed unannounced. v1.11.3 went the same way earlier today until it was caught by hand, which is the argument against leaving it to whoever is paying attention. Each release now has docs/releases/vX.Y.Z.md, written in the same commit as the version bump, so the notes are reviewed in git rather than typed into a web form afterwards. scripts/release-notes.mjs concatenates every file from a given tag downwards, newest first, and the release workflow publishes that as the body. A tag whose file is missing fails the job before the build even starts, so a release without notes cannot be published at all. generate_release_notes is gone. The 25 files are a split of the cumulative body that v1.12.0 already carried, so no section was rewritten. Verified by reassembling v1.12.0 from the files and diffing it against the published body: identical once separators and blank lines are normalised. Ordering is the one thing an assembler can get quietly wrong, and it has a test: sorting tags as strings puts v1.9.1 above v1.10.0 and would drop a release out of the middle of every body. Refusing an unknown tag has a test too, because that refusal is the whole gate. Not done: the bodies of v1.5.0 and older are left as they are, and no release title was changed. The workflow change is unexercised until the next tag is pushed. Tests: 260 pass (+5). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Manrn3qdrTJFz3C4o9PPFL
61 lines
2.5 KiB
JavaScript
61 lines
2.5 KiB
JavaScript
// Assembles a GitHub Release body from docs/releases/vX.Y.Z.md, newest first.
|
|
//
|
|
// AGENTS.md requires every tag to carry its own "What's new" plus every earlier
|
|
// release's, so the latest tag always tells the full story. That rule was a human
|
|
// convention and it was missed on nine tags in a row, which left v1.5.0 as the last
|
|
// release anyone could read while region discovery landed unannounced. Here the rule is
|
|
// mechanical: the workflow calls this before publishing, so a tag whose notes file is
|
|
// missing fails the job instead of shipping a body that is only a changelog link.
|
|
//
|
|
// Usage: node scripts/release-notes.mjs v1.12.0 > RELEASE_BODY.md
|
|
import { readdirSync, readFileSync } from 'node:fs';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { join, dirname } from 'node:path';
|
|
|
|
const SEPARATOR = '\n\n---\n\n';
|
|
|
|
// compareTags orders tags newest first. Ordering by string puts v1.9.1 above v1.10.0,
|
|
// which is the one mistake that would silently drop a release out of the middle of a
|
|
// body, so the comparison is on the numeric components.
|
|
export function compareTags(a, b) {
|
|
const na = a.replace(/^v/, '').split('.').map(Number);
|
|
const nb = b.replace(/^v/, '').split('.').map(Number);
|
|
for (let i = 0; i < Math.max(na.length, nb.length); i++) {
|
|
const d = (nb[i] || 0) - (na[i] || 0);
|
|
if (d) return d;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
// assembleBody returns the body for `tag`: its own section plus every OLDER one, newest
|
|
// first. Newer sections are excluded so that re-publishing an old tag stays truthful
|
|
// about what that release contained.
|
|
export function assembleBody(entries, tag) {
|
|
if (!entries.some((e) => e.tag === tag)) {
|
|
throw new Error('no release notes for ' + tag + ' — expected docs/releases/' + tag + '.md');
|
|
}
|
|
return entries
|
|
.filter((e) => compareTags(e.tag, tag) >= 0)
|
|
.sort((x, y) => compareTags(x.tag, y.tag))
|
|
.map((e) => e.text.trim())
|
|
.join(SEPARATOR) + '\n';
|
|
}
|
|
|
|
export function readEntries(dir) {
|
|
return readdirSync(dir)
|
|
.filter((f) => /^v\d+\.\d+\.\d+\.md$/.test(f))
|
|
.map((f) => ({ tag: f.replace(/\.md$/, ''), text: readFileSync(join(dir, f), 'utf8') }));
|
|
}
|
|
|
|
if (process.argv[1] && fileURLToPath(import.meta.url) === process.argv[1]) {
|
|
const tag = process.argv[2];
|
|
if (!tag) { console.error('usage: node scripts/release-notes.mjs <tag>'); process.exit(2); }
|
|
const dir = join(dirname(dirname(fileURLToPath(import.meta.url))), 'docs', 'releases');
|
|
try {
|
|
process.stdout.write(assembleBody(readEntries(dir), tag));
|
|
} catch (e) {
|
|
console.error(e.message);
|
|
process.exit(1);
|
|
}
|
|
}
|