Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions scripts/release-notes.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,28 @@ function readReleaseNotes(root = path.resolve(__dirname, '..')) {
}

function validateReleaseNotes(notes, version) {
const visibleNotes = notes.replace(/<!--[\s\S]*?-->/g, '').trim();
const failures = [];
const expectedHeading = '## Changes in `v' + version + ':`';
const firstHeadingIndex = notes.indexOf('## Changes in `v');
const firstHeadingIndex = visibleNotes.indexOf('## Changes in `v');
const firstHeadingEnd =
firstHeadingIndex < 0 ? notes.length : notes.indexOf('\n## Changes in `v', firstHeadingIndex + 1);
firstHeadingIndex < 0
? visibleNotes.length
: visibleNotes.indexOf('\n## Changes in `v', firstHeadingIndex + 1);
const currentRelease =
firstHeadingIndex < 0
? ''
: notes.slice(firstHeadingIndex, firstHeadingEnd < 0 ? notes.length : firstHeadingEnd);
const preamble = notes.slice(0, firstHeadingIndex < 0 ? notes.length : firstHeadingIndex);
: visibleNotes.slice(
firstHeadingIndex,
firstHeadingEnd < 0 ? visibleNotes.length : firstHeadingEnd,
);
const preamble = visibleNotes.slice(
0,
firstHeadingIndex < 0 ? visibleNotes.length : firstHeadingIndex,
);
const isPrerelease = version.includes('beta') || version.includes('alpha');

if (!notes.startsWith('> [!')) {
if (!visibleNotes.startsWith('> [!')) {
failures.push('CHANGELOG.md must begin with a release notice');
}
if (!currentRelease.startsWith(expectedHeading)) {
Expand Down
9 changes: 9 additions & 0 deletions scripts/release-notes.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ test('rejects a beta banner for stable release notes', () => {
assert.equal(failures.some((failure) => failure.includes('beta-build banner')), true);
});

test('ignores a historical beta banner inside an HTML comment', () => {
const notes = [
'<!-- > [!NOTE]',
'> This is a Beta build. -->',
notesFor('0.12.0', '> [!IMPORTANT]\n> Stable release'),
].join('\n');
assert.deepEqual(validateReleaseNotes(notes, '0.12.0'), []);
});

test('requires the one-time v0.11.0 recovery advisory in v0.11.1 notes', () => {
const failures = validateReleaseNotes(notesFor('0.11.1'), '0.11.1');
assert.equal(failures.some((failure) => failure.includes('manual-upgrade advisory')), true);
Expand Down