Skip to content
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
18 changes: 15 additions & 3 deletions .github/scripts/release-notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* - pr: merged PRs linked to commits in range, filtered by changed files vs releaseNotesPaths
* - commits: path-filtered git log (escape hatch)
*
* PR lines: title by @author in #N (PR opener). @mentions power GitHub’s release avatar strip.
*
* Usage:
* node release-notes.js <fullTag> <tagPrefix> <pathsJson> [mode]
* Env: GITHUB_REPOSITORY=owner/name, RELEASE_NOTES_MODE, GH_TOKEN or GITHUB_TOKEN
Expand Down Expand Up @@ -148,6 +150,11 @@ function renderCommitMode(paths, prev, tag) {
return `## Changes (paths: ${paths.join(', ')})\n\n${body}\n`;
}

function formatPrLine(p) {
const by = p.author_login ? ` by @${p.author_login}` : '';
return `- ${p.title}${by} in [#${p.number}](${p.html_url})`;
}

async function renderPrMode(tag, tagPrefix, paths) {
const { owner, repo } = parseRepo();
const tags = listTagsForPrefix(tagPrefix);
Expand Down Expand Up @@ -180,13 +187,18 @@ async function renderPrMode(tag, tagPrefix, paths) {
continue;
}
const detail = await ghApiJson(`repos/${owner}/${repo}/pulls/${num}`);
const authorLogin =
detail.user && typeof detail.user.login === 'string'
? detail.user.login
: null;
included.push({
number: num,
title: detail.title || `PR #${num}`,
html_url:
detail.html_url ||
`https://github.com/${owner}/${repo}/pull/${num}`,
merged_at: detail.merged_at || null,
author_login: authorLogin,
});
}

Expand All @@ -197,9 +209,7 @@ async function renderPrMode(tag, tagPrefix, paths) {
return b.number - a.number;
});

const lines = included.map(
p => `- ${p.title} ([#${p.number}](${p.html_url}))`,
);
const lines = included.map(formatPrLine);

const orphanLines = [];
for (let i = 0; i < shas.length; i += 1) {
Expand All @@ -224,6 +234,8 @@ async function renderPrMode(tag, tagPrefix, paths) {
md += `\n### Other commits (no linked PR)\n\n${orphanLines.join('\n')}\n`;
}

md += "### Thank you to all the contributors who helped make this release.\n\n";

return md;
}

Expand Down
Loading