Skip to content

Commit

Permalink
actions: Create script for generating release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
xTVaser authored and TellowKrinkle committed Nov 2, 2021
1 parent c4e5a21 commit b7bdbff
Show file tree
Hide file tree
Showing 4 changed files with 285 additions and 0 deletions.
@@ -0,0 +1,2 @@
node_modules/
*.md
64 changes: 64 additions & 0 deletions .github/workflows/scripts/releases/generate-release-notes/index.js
@@ -0,0 +1,64 @@
import { Octokit } from "@octokit/rest";
import { throttling } from "@octokit/plugin-throttling";
import { retry } from "@octokit/plugin-retry";
Octokit.plugin(throttling);
Octokit.plugin(retry);
const octokit = new Octokit({
auth: process.env.GITHUB_TOKEN,
userAgent: 'PCSX2/pcsx2',
log: {
debug: () => { },
info: () => { },
warn: console.warn,
error: console.error
},
throttle: {
onRateLimit: (retryAfter, options) => {
octokit.log.warn(
`Request quota exhausted for request ${options.method} ${options.url}`
);

// Retry twice after hitting a rate limit error, then give up
if (options.request.retryCount <= 2) {
console.log(`Retrying after ${retryAfter} seconds!`);
return true;
}
},
onAbuseLimit: (retryAfter, options) => {
// does not retry, only logs a warning
octokit.log.warn(
`Abuse detected for request ${options.method} ${options.url}`
);
},
}
});

var args = process.argv.slice(2);
let commitSha = process.env.COMMIT_SHA;

console.log(`Searching for Commit - ${commitSha}`);

const { data: commit } = await octokit.rest.repos.getCommit({
owner: "PCSX2",
repo: "pcsx2",
ref: commitSha,
});

const { data: associatedPulls } = await octokit.rest.repos.listPullRequestsAssociatedWithCommit({
owner: "PCSX2",
repo: "pcsx2",
commit_sha: commit.sha,
});

let releaseNotes = ``;

if (associatedPulls.length == 0) {
releaseNotes += `- ${commit.commit.message}\n`;
} else {
for (var j = 0; j < associatedPulls.length; j++) {
releaseNotes += `- [${associatedPulls[j].title}](${associatedPulls[j].html_url})\n`;
}
}

import * as fs from 'fs';
fs.writeFileSync('./release-notes.md', releaseNotes);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -0,0 +1,17 @@
{
"name": "generate-release-notes",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@octokit/plugin-retry": "^3.0.9",
"@octokit/plugin-throttling": "^3.5.2",
"@octokit/rest": "^18.12.0"
}
}

0 comments on commit b7bdbff

Please sign in to comment.