chore: changelog (#5851)
* fix: modrinth hosting changelog in app changelog for github releases * chore: changelog
This commit is contained in:
66
.github/workflows/theseus-release.yml
vendored
66
.github/workflows/theseus-release.yml
vendored
@@ -60,16 +60,70 @@ jobs:
|
||||
const fs = require('fs');
|
||||
const version = process.env.VERSION.replace(/^v/, '');
|
||||
const src = fs.readFileSync('packages/blog/changelog.ts', 'utf8');
|
||||
const escaped = version.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
const re = new RegExp("product:\\s*'app',\\s*version:\\s*'" + escaped + "',\\s*body:\\s*`([\\s\\S]*?)`,\\s*\\}");
|
||||
const m = src.match(re);
|
||||
if (!m) {
|
||||
|
||||
// Parse every entry in the VERSIONS array, preserving their order
|
||||
// (which is reverse chronological).
|
||||
const entryRe = /\{\s*date:\s*`([^`]+)`,\s*product:\s*'(\w+)',(?:\s*version:\s*[`']([^`']+)[`'],)?\s*body:\s*`([\s\S]*?)`,\s*\}/g;
|
||||
const entries = [];
|
||||
let match;
|
||||
while ((match = entryRe.exec(src)) !== null) {
|
||||
entries.push({
|
||||
date: match[1],
|
||||
product: match[2],
|
||||
version: match[3],
|
||||
body: match[4],
|
||||
});
|
||||
}
|
||||
|
||||
const currentIdx = entries.findIndex(
|
||||
(e) => e.product === 'app' && e.version === version,
|
||||
);
|
||||
if (currentIdx === -1) {
|
||||
console.error(`No app changelog entry found for version ${version}`);
|
||||
process.exit(1);
|
||||
}
|
||||
fs.writeFileSync('release-notes.md', m[1]);
|
||||
|
||||
// Find the surrounding app entries so we can scope hosting changes to
|
||||
// exactly what shipped between the previous app release and this one.
|
||||
// Entries are in reverse chronological order, so newer entries have
|
||||
// smaller indices than older entries.
|
||||
let newerAppIdx = -1;
|
||||
for (let i = currentIdx - 1; i >= 0; i--) {
|
||||
if (entries[i].product === 'app') {
|
||||
newerAppIdx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
let previousAppIdx = entries.length;
|
||||
for (let i = currentIdx + 1; i < entries.length; i++) {
|
||||
if (entries[i].product === 'app') {
|
||||
previousAppIdx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const hostingEntries = [];
|
||||
for (let i = newerAppIdx + 1; i < previousAppIdx; i++) {
|
||||
if (entries[i].product === 'hosting') {
|
||||
hostingEntries.push(entries[i]);
|
||||
}
|
||||
}
|
||||
|
||||
let output = entries[currentIdx].body;
|
||||
if (hostingEntries.length > 0) {
|
||||
// Demote any top-level section headings inside hosting bodies so
|
||||
// they nest cleanly under the "Modrinth Hosting (included)" header.
|
||||
const demoteHeadings = (body) =>
|
||||
body.replace(/^(#{1,5})\s/gm, (_, hashes) => `${hashes}# `);
|
||||
const hostingBody = hostingEntries
|
||||
.map((e) => demoteHeadings(e.body))
|
||||
.join('\n\n');
|
||||
output += `\n\n---\n\n## Modrinth Hosting (included)\n\n${hostingBody}`;
|
||||
}
|
||||
|
||||
fs.writeFileSync('release-notes.md', output);
|
||||
console.log(`Extracted changelog for app ${version}:`);
|
||||
console.log(m[1]);
|
||||
console.log(output);
|
||||
EOF
|
||||
|
||||
- name: 🛠️ Generate version manifest
|
||||
|
||||
Reference in New Issue
Block a user