2022-07-09 01:51:28 +03:00
|
|
|
#!/usr/bin/env node --redirect-warnings=/dev/null
|
|
|
|
|
|
|
|
const { execFileSync } = require("child_process");
|
|
|
|
const { GITHUB_ACCESS_TOKEN } = process.env;
|
2023-11-08 19:40:53 +03:00
|
|
|
const PR_REGEX = /#\d+/; // Ex: matches on #4241
|
2023-05-22 06:38:01 +03:00
|
|
|
const FIXES_REGEX = /(fixes|closes|completes) (.+[/#]\d+.*)$/im;
|
2022-07-09 01:51:28 +03:00
|
|
|
|
|
|
|
main();
|
|
|
|
|
|
|
|
async function main() {
|
2022-11-02 20:55:48 +03:00
|
|
|
// Get the last two preview tags
|
2022-07-09 01:51:28 +03:00
|
|
|
const [newTag, oldTag] = execFileSync(
|
|
|
|
"git",
|
|
|
|
["tag", "--sort", "-committerdate"],
|
2023-11-08 19:40:53 +03:00
|
|
|
{ encoding: "utf8" },
|
2022-07-09 01:51:28 +03:00
|
|
|
)
|
|
|
|
.split("\n")
|
2023-05-22 06:38:01 +03:00
|
|
|
.filter((t) => t.startsWith("v") && t.endsWith("-pre"));
|
2022-07-09 01:51:28 +03:00
|
|
|
|
|
|
|
// Print the previous release
|
|
|
|
console.log(`Changes from ${oldTag} to ${newTag}\n`);
|
|
|
|
|
2022-09-28 11:40:30 +03:00
|
|
|
let hasProtocolChanges = false;
|
|
|
|
try {
|
2023-11-08 19:40:53 +03:00
|
|
|
execFileSync("git", [
|
|
|
|
"diff",
|
|
|
|
oldTag,
|
|
|
|
newTag,
|
|
|
|
"--exit-code",
|
|
|
|
"--",
|
|
|
|
"crates/rpc",
|
|
|
|
]).status != 0;
|
2022-09-28 11:40:30 +03:00
|
|
|
} catch (error) {
|
|
|
|
hasProtocolChanges = true;
|
|
|
|
}
|
2022-07-09 01:51:28 +03:00
|
|
|
|
|
|
|
if (hasProtocolChanges) {
|
2023-11-08 19:40:53 +03:00
|
|
|
console.warn(
|
|
|
|
"\033[31;1;4mRPC protocol changes, server should be re-deployed\033[0m\n",
|
|
|
|
);
|
2022-07-09 01:51:28 +03:00
|
|
|
} else {
|
2022-09-28 11:40:30 +03:00
|
|
|
console.log("No RPC protocol changes\n");
|
2022-07-09 01:51:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the PRs merged between those two tags.
|
2023-05-22 07:02:19 +03:00
|
|
|
const pullRequestNumbers = getPullRequestNumbers(oldTag, newTag);
|
2022-07-09 01:51:28 +03:00
|
|
|
|
2022-11-02 20:55:48 +03:00
|
|
|
// Get the PRs that were cherry-picked between main and the old tag.
|
2023-11-08 19:40:53 +03:00
|
|
|
const existingPullRequestNumbers = new Set(
|
|
|
|
getPullRequestNumbers("main", oldTag),
|
|
|
|
);
|
2023-05-22 06:38:01 +03:00
|
|
|
|
2022-11-02 20:55:48 +03:00
|
|
|
// Filter out those existing PRs from the set of new PRs.
|
2023-11-08 19:40:53 +03:00
|
|
|
const newPullRequestNumbers = pullRequestNumbers.filter(
|
|
|
|
(number) => !existingPullRequestNumbers.has(number),
|
|
|
|
);
|
2022-11-02 20:55:48 +03:00
|
|
|
|
2022-07-09 01:51:28 +03:00
|
|
|
// Fetch the pull requests from the GitHub API.
|
2023-05-22 07:02:19 +03:00
|
|
|
console.log("Merged Pull requests:");
|
2022-11-02 20:55:48 +03:00
|
|
|
for (const pullRequestNumber of newPullRequestNumbers) {
|
2022-07-09 01:51:28 +03:00
|
|
|
const webURL = `https://github.com/zed-industries/zed/pull/${pullRequestNumber}`;
|
|
|
|
const apiURL = `https://api.github.com/repos/zed-industries/zed/pulls/${pullRequestNumber}`;
|
|
|
|
|
|
|
|
const response = await fetch(apiURL, {
|
|
|
|
headers: {
|
|
|
|
Authorization: `token ${GITHUB_ACCESS_TOKEN}`,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
// Print the pull request title and URL.
|
|
|
|
const pullRequest = await response.json();
|
2023-11-08 19:40:53 +03:00
|
|
|
const releaseNotesHeader = /^\s*(?:Release )?Notes\s*:(.+)/ims;
|
|
|
|
|
|
|
|
let releaseNotes = pullRequest.body || "";
|
|
|
|
const captures = releaseNotesHeader.exec(releaseNotes);
|
|
|
|
const notes = captures ? captures[1] : "MISSING";
|
|
|
|
const skippableNoteRegex = /^\s*-?\s*n\/?a\s*/ims;
|
|
|
|
|
|
|
|
if (skippableNoteRegex.exec(notes) != null) {
|
|
|
|
continue;
|
|
|
|
}
|
2022-07-09 01:51:28 +03:00
|
|
|
console.log("*", pullRequest.title);
|
2023-05-22 07:02:19 +03:00
|
|
|
console.log(" PR URL: ", webURL);
|
2022-07-09 01:51:28 +03:00
|
|
|
|
|
|
|
// If the pull request contains a 'closes' line, print the closed issue.
|
2023-05-22 06:38:01 +03:00
|
|
|
const fixesMatch = (pullRequest.body || "").match(FIXES_REGEX);
|
2022-07-09 01:51:28 +03:00
|
|
|
if (fixesMatch) {
|
|
|
|
const fixedIssueURL = fixesMatch[2];
|
2023-05-22 07:02:19 +03:00
|
|
|
console.log(" Issue URL: ", fixedIssueURL);
|
2022-07-09 01:51:28 +03:00
|
|
|
}
|
2023-05-22 06:38:01 +03:00
|
|
|
|
2023-11-08 19:40:53 +03:00
|
|
|
releaseNotes = notes.trim().split("\n");
|
|
|
|
console.log(" Release Notes:");
|
2023-05-22 21:44:05 +03:00
|
|
|
|
2023-11-08 19:40:53 +03:00
|
|
|
for (const line of releaseNotes) {
|
|
|
|
console.log(` ${line}`);
|
2023-05-22 06:38:01 +03:00
|
|
|
}
|
2023-05-22 07:02:19 +03:00
|
|
|
|
2023-11-08 19:40:53 +03:00
|
|
|
console.log();
|
2022-07-09 01:51:28 +03:00
|
|
|
}
|
|
|
|
}
|
2023-05-22 06:38:01 +03:00
|
|
|
|
|
|
|
function getPullRequestNumbers(oldTag, newTag) {
|
|
|
|
const pullRequestNumbers = execFileSync(
|
|
|
|
"git",
|
2023-11-08 19:40:53 +03:00
|
|
|
["log", `${oldTag}..${newTag}`, "--oneline"],
|
|
|
|
{ encoding: "utf8" },
|
2023-05-22 06:38:01 +03:00
|
|
|
)
|
|
|
|
.split("\n")
|
2023-11-08 19:40:53 +03:00
|
|
|
.filter((line) => line.length > 0)
|
|
|
|
.map((line) => {
|
2023-05-22 06:38:01 +03:00
|
|
|
const match = line.match(/#(\d+)/);
|
|
|
|
return match ? match[1] : null;
|
|
|
|
})
|
2023-11-08 19:40:53 +03:00
|
|
|
.filter((line) => line);
|
2023-05-22 06:38:01 +03:00
|
|
|
|
2023-05-22 07:02:19 +03:00
|
|
|
return pullRequestNumbers;
|
2023-05-22 06:38:01 +03:00
|
|
|
}
|