Skip to content

Assets is now category in the release notes #3005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 48 additions & 35 deletions scripts/prReleaseNotesCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,31 +80,30 @@ function isSilent(pr) {
return false;
}

function getPRsByType(PRs) {
const silentPRs = [],
features = [],
web = [],
fixes = [],
infra = [],
others = [];
function getPRsByType(PRs, categories) {
const categorizedPRs = [];

categories.forEach(category => {
categorizedPRs.push({name: category.name, PRs: [], title: category.title});
});

PRs.forEach(pr => {
if (isSilent(pr)) {
silentPRs.push(pr);
} else if (pr.branch.startsWith('feat/')) {
features.push(pr);
} else if (pr.branch.startsWith('web/')) {
web.push(pr);
} else if (pr.branch.startsWith('fix/')) {
fixes.push(pr);
} else if (pr.branch.startsWith('infra/')) {
infra.push(pr);
const category = categories.find(category => {
return pr.branch.toLowerCase().startsWith(category.branch);
});
if (category) {
const foundCategory = categorizedPRs.find(cat => cat.name === category.name);
foundCategory.PRs.push(pr);
} else if (isSilent(pr)) {
const silentCategory = categorizedPRs.find(cat => cat.name === 'silent');
silentCategory.PRs.push(pr);
} else {
others.push(pr);
const otherCategory = categorizedPRs.find(cat => cat.name === 'others');
otherCategory.PRs.push(pr);
}
});

return {silentPRs, features, web, fixes, infra, others};
return categorizedPRs;
}

function getLine(log, requester, prNumber) {
Expand Down Expand Up @@ -153,34 +152,47 @@ function getReleaseNotesForType(PRs, title) {
return releaseNotes;
}

async function _generateReleaseNotes(latestVersion, newVersion, githubToken, fileNamePrefix, repo, header, tagPrefix) {
async function _generateReleaseNotes(latestVersion,
newVersion,
githubToken,
fileNamePrefix,
repo,
header,
tagPrefix,
categories) {
const latestReleaseDate = fetchLatestReleaseDate(tagPrefix, latestVersion);
const PRs = await fetchMergedPRs(latestReleaseDate, repo, githubToken);
if (!PRs) {
return;
}

const {silentPRs, features, web, fixes, infra, others} = getPRsByType(PRs);
const prCategories = [
{name: 'features', branch: 'feat/', title: ':gift: Features'},
{name: 'web', branch: 'web/', title: ':spider_web: Web support'},
{name: 'fixes', branch: 'fix/', title: ':wrench: Fixes'},
{name: 'infra', branch: 'infra/', title: ':gear: Maintenance & Infra'},
...categories,
{name: 'others', branch: '', title: 'OTHERS'},
{
name: 'silent',
branch: '',
title: '// Silent - these PRs did not have a changelog or were left out for some other reason, is it on purpose?'
}
];

const categorizedPRs = getPRsByType(PRs, prCategories);
let releaseNotes = header;

releaseNotes += getTitle(':rocket: What’s New?');

releaseNotes += getReleaseNotesForType(features, ':gift: Features');

releaseNotes += getReleaseNotesForType(web, ':spider_web: Web support');

releaseNotes += getReleaseNotesForType(fixes, ':wrench: Fixes');

releaseNotes += getReleaseNotesForType(infra, ':gear: Maintenance & Infra');
categorizedPRs.forEach(({PRs, title}) => {
if (PRs.length > 0) {
releaseNotes += getReleaseNotesForType(PRs, title);
}
});

releaseNotes += getTitle(':bulb: Deprecations & Migrations');

releaseNotes += getReleaseNotesForType(others, 'OTHERS');

releaseNotes += getReleaseNotesForType(silentPRs,
'// Silent - these PRs did not have a changelog or were left out for some other reason, is it on purpose?');

fs.writeFileSync(`${process.env.HOME}/Downloads/${fileNamePrefix}-release-notes_${newVersion}.txt`, releaseNotes, {
encoding: 'utf8'
});
Expand All @@ -194,7 +206,8 @@ async function generateReleaseNotes(latestVersion,
fileNamePrefix,
repo,
header = '',
tagPrefix = '') {
tagPrefix = '',
categories = []) {
let latestVer, newVer;
const rl = readline.createInterface({
input: process.stdin,
Expand All @@ -212,7 +225,7 @@ async function generateReleaseNotes(latestVersion,
rl.on('close', () => {
console.info(`Current latest version is v${latestVer}`);
console.info(`Generating release notes out or PRs for v${newVer}`);
_generateReleaseNotes(latestVer, newVer, githubToken, fileNamePrefix, repo, header, tagPrefix);
_generateReleaseNotes(latestVer, newVer, githubToken, fileNamePrefix, repo, header, tagPrefix, categories);
});
}

Expand Down