mirror of
https://github.com/maputnik/editor.git
synced 2025-12-07 14:50:02 +00:00
Was missing trailing `, causing [this failure](https://github.com/maplibre/maputnik/actions/runs/10619718712/job/29437920164)
49 lines
1.5 KiB
JavaScript
Executable File
49 lines
1.5 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
// Copied from maplibre/maplibre-gl-js
|
|
// https://github.com/maplibre/maplibre-gl-js/blob/bc70bc559cea5c987fa1b79fd44766cef68bbe28/build/release-notes.js
|
|
|
|
import * as fs from 'fs';
|
|
|
|
const changelogPath = 'CHANGELOG.md';
|
|
const changelog = fs.readFileSync(changelogPath, 'utf8');
|
|
|
|
/*
|
|
Parse the raw changelog text and split it into individual releases.
|
|
|
|
This regular expression:
|
|
- Matches lines starting with "## x.x.x".
|
|
- Groups the version number.
|
|
- Skips the (optional) release date.
|
|
- Groups the changelog content.
|
|
- Ends when another "## x.x.x" is found.
|
|
*/
|
|
const regex = /^## (\d+\.\d+\.\d+.*?)\n(.+?)(?=\n^## \d+\.\d+\.\d+.*?\n)/gms;
|
|
|
|
let releaseNotes = [];
|
|
let match;
|
|
// eslint-disable-next-line no-cond-assign
|
|
while (match = regex.exec(changelog)) {
|
|
releaseNotes.push({
|
|
'version': match[1],
|
|
'changelog': match[2].trim(),
|
|
});
|
|
}
|
|
|
|
const latest = releaseNotes[0];
|
|
const previous = releaseNotes[1];
|
|
|
|
// Print the release notes template.
|
|
|
|
let header = 'Changes since previous version'
|
|
if (previous) {
|
|
header = `https://github.com/maplibre/maputnik
|
|
[Changes](https://github.com/maplibre/maputnik/compare/v${previous.version}...v${latest.version}) since [Maputnik v${previous.version}](https://github.com/maplibre/maputnik/releases/tag/v${previous.version})`
|
|
}
|
|
const templatedReleaseNotes = `${header}
|
|
|
|
${latest.changelog}`;
|
|
|
|
// eslint-disable-next-line eol-last
|
|
process.stdout.write(templatedReleaseNotes.trimEnd());
|