mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-09 21:26:14 +03:00
cc1325d6f9
Now, this script is only useful for the preview channel's releases. The stable channel's release notes can be mostly copied from the existing preview releases notes. Co-authored-by: Joseph Lyons <joseph@zed.dev>
96 lines
2.7 KiB
JavaScript
Executable File
96 lines
2.7 KiB
JavaScript
Executable File
#!/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() {
|
|
// Get the last two preview tags
|
|
const [newTag, oldTag] = execFileSync(
|
|
"git",
|
|
["tag", "--sort", "-committerdate"],
|
|
{ encoding: "utf8" }
|
|
)
|
|
.split("\n")
|
|
.filter((t) => t.startsWith("v") && t.endsWith('-pre'));
|
|
|
|
// Print the previous release
|
|
console.log(`Changes from ${oldTag} to ${newTag}\n`);
|
|
|
|
let hasProtocolChanges = false;
|
|
try {
|
|
execFileSync("git", ["diff", oldTag, newTag, "--exit-code", "--", "crates/rpc"]).status != 0;
|
|
} catch (error) {
|
|
hasProtocolChanges = true;
|
|
}
|
|
|
|
if (hasProtocolChanges) {
|
|
console.warn("\033[31;1;4mRPC protocol changes, server should be re-deployed\033[0m\n");
|
|
} else {
|
|
console.log("No RPC protocol changes\n");
|
|
}
|
|
|
|
// 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]);
|
|
|
|
// 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));
|
|
|
|
// Fetch the pull requests from the GitHub API.
|
|
console.log("Merged Pull requests:")
|
|
for (const pullRequestNumber of newPullRequestNumbers) {
|
|
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.
|
|
const fixesMatch = (pullRequest.body || '').match(FIXES_REGEX);
|
|
if (fixesMatch) {
|
|
const fixedIssueURL = fixesMatch[2];
|
|
console.log(" Issue: ", fixedIssueURL);
|
|
}
|
|
}
|
|
}
|