2022-07-08 22:51:28 +00:00
|
|
|
#!/usr/bin/env node --redirect-warnings=/dev/null
|
|
|
|
|
|
|
|
const { execFileSync } = require("child_process");
|
|
|
|
const { GITHUB_ACCESS_TOKEN } = process.env;
|
|
|
|
const PR_REGEX = /pull request #(\d+)/;
|
|
|
|
const FIXES_REGEX = /(fixes|closes) (.+[/#]\d+.*)$/im;
|
|
|
|
|
|
|
|
main();
|
|
|
|
|
|
|
|
async function main() {
|
2022-11-02 17:55:48 +00:00
|
|
|
// Get the last two preview tags
|
2022-07-08 22:51:28 +00:00
|
|
|
const [newTag, oldTag] = execFileSync(
|
|
|
|
"git",
|
|
|
|
["tag", "--sort", "-committerdate"],
|
|
|
|
{ encoding: "utf8" }
|
|
|
|
)
|
|
|
|
.split("\n")
|
2022-11-02 17:55:48 +00:00
|
|
|
.filter((t) => t.startsWith("v") && t.endsWith('-pre'));
|
2022-07-08 22:51:28 +00:00
|
|
|
|
|
|
|
// Print the previous release
|
|
|
|
console.log(`Changes from ${oldTag} to ${newTag}\n`);
|
|
|
|
|
2022-09-28 08:40:30 +00:00
|
|
|
let hasProtocolChanges = false;
|
|
|
|
try {
|
|
|
|
execFileSync("git", ["diff", oldTag, newTag, "--exit-code", "--", "crates/rpc"]).status != 0;
|
|
|
|
} catch (error) {
|
|
|
|
hasProtocolChanges = true;
|
|
|
|
}
|
2022-07-08 22:51:28 +00:00
|
|
|
|
|
|
|
if (hasProtocolChanges) {
|
2022-09-28 08:40:30 +00:00
|
|
|
console.warn("\033[31;1;4mRPC protocol changes, server should be re-deployed\033[0m\n");
|
2022-07-08 22:51:28 +00:00
|
|
|
} else {
|
2022-09-28 08:40:30 +00:00
|
|
|
console.log("No RPC protocol changes\n");
|
2022-07-08 22:51:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get the PRs merged between those two tags.
|
|
|
|
const pullRequestNumbers = execFileSync(
|
|
|
|
"git",
|
|
|
|
[
|
|
|
|
"log",
|
|
|
|
`${oldTag}..${newTag}`,
|
|
|
|
"--oneline",
|
|
|
|
"--grep",
|
|
|
|
"Merge pull request",
|
|
|
|
],
|
|
|
|
{ encoding: "utf8" }
|
|
|
|
)
|
|
|
|
.split("\n")
|
|
|
|
.filter((line) => line.length > 0)
|
|
|
|
.map((line) => line.match(PR_REGEX)[1]);
|
|
|
|
|
2022-11-02 17:55:48 +00:00
|
|
|
// Get the PRs that were cherry-picked between main and the old tag.
|
|
|
|
const existingPullRequestNumbers = new Set(execFileSync(
|
|
|
|
"git",
|
|
|
|
[
|
|
|
|
"log",
|
|
|
|
`main..${oldTag}`,
|
|
|
|
"--oneline",
|
|
|
|
"--grep",
|
|
|
|
"Merge pull request",
|
|
|
|
],
|
|
|
|
{ encoding: "utf8" }
|
|
|
|
)
|
|
|
|
.split("\n")
|
|
|
|
.filter((line) => line.length > 0)
|
|
|
|
.map((line) => line.match(PR_REGEX)[1]));
|
|
|
|
|
|
|
|
// Filter out those existing PRs from the set of new PRs.
|
|
|
|
const newPullRequestNumbers = pullRequestNumbers.filter(number => !existingPullRequestNumbers.has(number));
|
|
|
|
|
2022-07-08 22:51:28 +00:00
|
|
|
// Fetch the pull requests from the GitHub API.
|
|
|
|
console.log("Merged Pull requests:")
|
2022-11-02 17:55:48 +00:00
|
|
|
for (const pullRequestNumber of newPullRequestNumbers) {
|
2022-07-08 22:51:28 +00: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();
|
|
|
|
console.log("*", pullRequest.title);
|
|
|
|
console.log(" URL: ", webURL);
|
|
|
|
|
|
|
|
// If the pull request contains a 'closes' line, print the closed issue.
|
2022-10-18 20:12:27 +00:00
|
|
|
const fixesMatch = (pullRequest.body || '').match(FIXES_REGEX);
|
2022-07-08 22:51:28 +00:00
|
|
|
if (fixesMatch) {
|
|
|
|
const fixedIssueURL = fixesMatch[2];
|
|
|
|
console.log(" Issue: ", fixedIssueURL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|