You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-09 10:22:46 +03:00
* Tidy reusable release workflow Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add ability to include upstream changes Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add ability to upload assets and gpg sign them Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update relative composite actions Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Wire up validating release tarball signature Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Validate release has expected assets Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Paths Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Use gpg outputs for email instead of scraping it ourselves Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * v6 Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Extract pre-release and post-merge-master scripts Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Reuse pre-release and post-merge-master scripts in gha Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Cull unused vars Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Revert Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove unused variables Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Simplify Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Simplify and fix merge-release-notes script Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Tidy release automation Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update release.sh * Move environment Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * s/includes/contains/ Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate uses syntax Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix action-repo calls Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix RELEASE_NOTES env Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix if check Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix gpg tag signing Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Cull stale params Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix sign-release-tarball paths being outside the workspace Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix gpg validation (of course wget uses `-O` and not `-o`) Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix expected asset assertion Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix release publish mode Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add support for ingest-changes to refer to a project without it being in node_modules Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
89 lines
2.7 KiB
JavaScript
Executable File
89 lines
2.7 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
|
|
const fs = require("fs");
|
|
|
|
async function getRelease(github, dependency) {
|
|
let owner;
|
|
let repo;
|
|
let tag;
|
|
if (dependency.includes("/") && dependency.includes("@")) {
|
|
owner = dependency.split("/")[0];
|
|
repo = dependency.split("/")[1].split("@")[0];
|
|
tag = dependency.split("@")[1];
|
|
} else {
|
|
const upstreamPackageJson = JSON.parse(fs.readFileSync(`./node_modules/${dependency}/package.json`, "utf8"));
|
|
[owner, repo] = upstreamPackageJson.repository.url.split("/").slice(-2);
|
|
tag = `v${upstreamPackageJson.version}`;
|
|
}
|
|
|
|
const response = await github.rest.repos.getReleaseByTag({
|
|
owner,
|
|
repo,
|
|
tag,
|
|
});
|
|
return response.data;
|
|
}
|
|
|
|
const main = async ({ github, releaseId, dependencies }) => {
|
|
const { GITHUB_REPOSITORY } = process.env;
|
|
const [owner, repo] = GITHUB_REPOSITORY.split("/");
|
|
|
|
const sections = new Map();
|
|
let heading = null;
|
|
for (const dependency of dependencies) {
|
|
const release = await getRelease(github, dependency);
|
|
for (const line of release.body.split("\n")) {
|
|
if (line.startsWith("#")) {
|
|
heading = line;
|
|
sections.set(heading, []);
|
|
continue;
|
|
}
|
|
if (heading && line) {
|
|
sections.get(heading).push(line);
|
|
}
|
|
}
|
|
}
|
|
|
|
const { data: release } = await github.rest.repos.getRelease({
|
|
owner,
|
|
repo,
|
|
release_id: releaseId,
|
|
});
|
|
|
|
heading = null;
|
|
const output = [];
|
|
for (const line of [...release.body.split("\n"), null]) {
|
|
if (line === null || line.startsWith("#")) {
|
|
if (heading && sections.has(heading)) {
|
|
const lastIsBlank = !output.at(-1)?.trim();
|
|
if (lastIsBlank) output.pop();
|
|
output.push(...sections.get(heading));
|
|
if (lastIsBlank) output.push("");
|
|
}
|
|
heading = line;
|
|
}
|
|
output.push(line);
|
|
}
|
|
|
|
return output.join("\n");
|
|
};
|
|
|
|
// This is just for testing locally
|
|
// Needs environment variables GITHUB_TOKEN & GITHUB_REPOSITORY
|
|
if (require.main === module) {
|
|
const { Octokit } = require("@octokit/rest");
|
|
const github = new Octokit({ auth: process.env.GITHUB_TOKEN });
|
|
if (process.argv.length < 4) {
|
|
// eslint-disable-next-line no-console
|
|
console.error("Usage: node merge-release-notes.js owner/repo:release_id npm-package-name ...");
|
|
process.exit(1);
|
|
}
|
|
const [releaseId, ...dependencies] = process.argv.slice(2);
|
|
main({ github, releaseId, dependencies }).then((output) => {
|
|
// eslint-disable-next-line no-console
|
|
console.log(output);
|
|
});
|
|
}
|
|
|
|
module.exports = main;
|