You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-07 23:02:56 +03:00
Saner Releases - improve changelog merging & allow pre-public testing (pack) (#4043)
* Switch prepublishOnly to prepack to catch errors earlier Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix merge-release-notes.js parsing Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Discard changes to yarn.lock * Update package.json --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
committed by
GitHub
parent
8007bc5fe8
commit
b46b31563e
@@ -6,7 +6,7 @@
|
|||||||
"node": ">=18.0.0"
|
"node": ">=18.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepublishOnly": "yarn build",
|
"prepack": "yarn build",
|
||||||
"start": "echo THIS IS FOR LEGACY PURPOSES ONLY. && babel src -w -s -d lib --verbose --extensions \".ts,.js\"",
|
"start": "echo THIS IS FOR LEGACY PURPOSES ONLY. && babel src -w -s -d lib --verbose --extensions \".ts,.js\"",
|
||||||
"clean": "rimraf lib",
|
"clean": "rimraf lib",
|
||||||
"build": "yarn build:dev",
|
"build": "yarn build:dev",
|
||||||
|
@@ -26,24 +26,38 @@ async function getRelease(github, dependency) {
|
|||||||
|
|
||||||
const HEADING_PREFIX = "## ";
|
const HEADING_PREFIX = "## ";
|
||||||
|
|
||||||
|
const categories = [
|
||||||
|
"🔒 SECURITY FIXES",
|
||||||
|
"🚨 BREAKING CHANGESd",
|
||||||
|
"🦖 Deprecations",
|
||||||
|
"✨ Features",
|
||||||
|
"🐛 Bug Fixes",
|
||||||
|
"🧰 Maintenance",
|
||||||
|
];
|
||||||
|
|
||||||
|
const parseReleaseNotes = (body, sections) => {
|
||||||
|
let heading = null;
|
||||||
|
for (const line of body.split("\n")) {
|
||||||
|
const trimmed = line.trim();
|
||||||
|
if (trimmed.startsWith(HEADING_PREFIX)) {
|
||||||
|
heading = trimmed.slice(HEADING_PREFIX.length);
|
||||||
|
if (!categories.includes(heading)) heading = null;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (heading && trimmed) {
|
||||||
|
sections[heading].push(trimmed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const main = async ({ github, releaseId, dependencies }) => {
|
const main = async ({ github, releaseId, dependencies }) => {
|
||||||
const { GITHUB_REPOSITORY } = process.env;
|
const { GITHUB_REPOSITORY } = process.env;
|
||||||
const [owner, repo] = GITHUB_REPOSITORY.split("/");
|
const [owner, repo] = GITHUB_REPOSITORY.split("/");
|
||||||
|
|
||||||
const sections = new Map();
|
const sections = Object.fromEntries(categories.map((cat) => [cat, []]));
|
||||||
let heading = null;
|
|
||||||
for (const dependency of dependencies) {
|
for (const dependency of dependencies) {
|
||||||
const release = await getRelease(github, dependency);
|
const release = await getRelease(github, dependency);
|
||||||
for (const line of release.body.split("\n")) {
|
parseReleaseNotes(release.body, sections);
|
||||||
if (line.startsWith(HEADING_PREFIX)) {
|
|
||||||
heading = line.trim();
|
|
||||||
sections.set(heading, []);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (heading && line) {
|
|
||||||
sections.get(heading).push(line.trim());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: release } = await github.rest.repos.getRelease({
|
const { data: release } = await github.rest.repos.getRelease({
|
||||||
@@ -52,36 +66,22 @@ const main = async ({ github, releaseId, dependencies }) => {
|
|||||||
release_id: releaseId,
|
release_id: releaseId,
|
||||||
});
|
});
|
||||||
|
|
||||||
const headings = ["🚨 BREAKING CHANGES", "🦖 Deprecations", "✨ Features", "🐛 Bug Fixes", "🧰 Maintenance"].map(
|
const intro = release.body.split(HEADING_PREFIX, 2)[0].trim();
|
||||||
(h) => HEADING_PREFIX + h,
|
|
||||||
);
|
|
||||||
|
|
||||||
heading = null;
|
let output = "";
|
||||||
const output = [];
|
if (intro) {
|
||||||
for (const line of [...release.body.split("\n"), null]) {
|
output = intro + "\n\n";
|
||||||
if (line === null || line.startsWith(HEADING_PREFIX)) {
|
|
||||||
// If we have a heading, and it's not the first in the list of pending headings, output the section.
|
|
||||||
// If we're processing the last line (null) then output all remaining sections.
|
|
||||||
while (headings.length > 0 && (line === null || (heading && headings[0] !== heading))) {
|
|
||||||
const heading = headings.shift();
|
|
||||||
if (sections.has(heading)) {
|
|
||||||
output.push(heading);
|
|
||||||
output.push(...sections.get(heading));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (heading && sections.has(heading)) {
|
for (const section in sections) {
|
||||||
const lastIsBlank = !output.at(-1)?.trim();
|
const lines = sections[section];
|
||||||
if (lastIsBlank) output.pop();
|
if (!lines.length) continue;
|
||||||
output.push(...sections.get(heading));
|
output += HEADING_PREFIX + section + "\n\n";
|
||||||
if (lastIsBlank) output.push("");
|
output += lines.join("\n");
|
||||||
}
|
output += "\n\n";
|
||||||
heading = line;
|
|
||||||
}
|
|
||||||
output.push(line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.join("\n");
|
return output;
|
||||||
};
|
};
|
||||||
|
|
||||||
// This is just for testing locally
|
// This is just for testing locally
|
||||||
|
Reference in New Issue
Block a user