1 | #!/usr/bin/env node
|
2 |
|
3 | import * as fs from 'fs';
|
4 | import semver from 'semver';
|
5 |
|
6 | const changelogPath = 'CHANGELOG.md';
|
7 | const changelog = fs.readFileSync(changelogPath, 'utf8');
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | const regex = /^## (\d+\.\d+\.\d+.*?)\n(.+?)(?=\n^## \d+\.\d+\.\d+.*?\n)/gms;
|
20 |
|
21 | let releaseNotes = [];
|
22 | let match;
|
23 |
|
24 | while (match = regex.exec(changelog)) {
|
25 | releaseNotes.push({
|
26 | 'version': match[1],
|
27 | 'changelog': match[2].trim(),
|
28 | });
|
29 | }
|
30 |
|
31 | const latest = releaseNotes[0];
|
32 | const previous = releaseNotes[1];
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | const templatedReleaseNotes = `https://github.com/maplibre/maplibre-gl-js
|
38 | [Changes](https://github.com/maplibre/maplibre-gl-js/compare/v${previous.version}...v${latest.version}) since [MapLibre GL JS v${previous.version}](https://github.com/maplibre/releases/tag/v${previous.version}):
|
39 |
|
40 | ${latest.changelog}
|
41 |
|
42 | ${semver.prerelease(latest.version) ? 'Pre-release version' : ''}`;
|
43 |
|
44 |
|
45 | process.stdout.write(templatedReleaseNotes.trimEnd()); |
\ | No newline at end of file |