fix: release.mjs reads a summary wrapped over several lines.
Release / release (push) Successful in 24s

This commit is contained in:
slawek committed 2026-11-06 19:06:46 +01:00
1 parent 00934a7c0c
commit 7c335c7ed2
2 files changed
+19 -7

No files matched your search

+7
View File
@@ -1,5 +1,12 @@
# Changelog
## 0.6.0-2
fix: release.mjs reads a summary wrapped over several lines.
- `release.mjs` takes the summary of the newest entry as the paragraph after its heading and joins
its lines with single spaces into the commit message.
## 0.6.0
feature: RowDialog validates a row as part of a larger value, such as a whole document with the row put in.
+12 -7
View File
@@ -10,8 +10,9 @@ const CHANGELOG = `${import.meta.dirname}/CHANGELOG.md`;
const usage = `Usage: release.mjs [-h|--help] [-n|--dry-run] [--no-push] [-m|--message <message>]
-m, --message commit message; default: the summary line of the newest CHANGELOG.md entry,
the line between blank lines right after its "## x.y.z" or "## x.y.z-n" heading
-m, --message commit message; default: the summary of the newest CHANGELOG.md entry, the
paragraph between blank lines right after its "## x.y.z" or "## x.y.z-n"
heading, its lines joined with single spaces
The tag is the version of the heading: x.y.z for a release of the code, which must be the version
of package.json and which the build workflow publishes, x.y.z-n, n from 2, for a later release
@@ -48,8 +49,8 @@ function git(...args) {
if (status !== 0) process.exit(status ?? 1);
}
// The newest entry: its version from the first "## x.y.z" or "## x.y.z-n" heading, n from 2, and its summary line when
// the heading is followed by a blank line, one line that is not a "-" item, and another blank line.
// The newest entry: its version from the first "## x.y.z" or "## x.y.z-n" heading, n from 2, and its summary when the
// heading is followed by a blank line and a paragraph that is not a "-" item; the paragraph's lines are joined with spaces.
const lines = readFileSync(CHANGELOG, 'utf8').split('\n');
const heading = lines.findIndex((line) => line.startsWith('## '));
if (heading === -1) fail(`${CHANGELOG} has no "## x.y.z" entry`);
@@ -65,12 +66,16 @@ const packageVersion = JSON.parse(readFileSync(`${import.meta.dirname}/package.j
if (revision === undefined && version !== packageVersion) {
fail(`${CHANGELOG}: ${tag} is not the version of package.json, ${packageVersion}`);
}
const [above, line, below] = lines.slice(heading + 1, heading + 4);
const summary = above?.trim() === '' && below?.trim() === '' && line?.trim() && !line.startsWith('-') && !line.startsWith('#') ? line.trim() : undefined;
const end = lines.findIndex((line, index) => index > heading + 1 && line.trim() === '');
const paragraph = end === -1 ? [] : lines.slice(heading + 2, end);
const summary =
lines[heading + 1]?.trim() === '' && paragraph.length > 0 && !paragraph[0].startsWith('-') && !paragraph.some((line) => line.startsWith('#'))
? paragraph.map((line) => line.trim()).join(' ')
: undefined;
const message = values.message ?? summary;
if (!message) {
fail(`no commit message: pass -m, or put a summary line between blank lines right after the newest heading of ${CHANGELOG}`);
fail(`no commit message: pass -m, or put a summary paragraph between blank lines right after the newest heading of ${CHANGELOG}`);
}
if (spawnSync('git', ['rev-parse', '-q', '--verify', `refs/tags/${tag}`], { cwd: import.meta.dirname }).status === 0) {