Skip to content
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

[infra] Adds community contribution section to the changelog script #14799

Merged
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
48 changes: 47 additions & 1 deletion scripts/releaseChangelog.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ async function main(argv) {

const changeLogMessages = [];
const prsLabelsMap = {};
const community = {
firstTimers: new Set(),
contributors: new Set(),
team: new Set(),
};
await Promise.all(
commitsItems.map(async (commitsItem) => {
const searchPullRequestId = commitsItem.commit.message.match(/\(#([0-9]+)\)/);
Expand All @@ -116,13 +121,31 @@ async function main(argv) {
}

const {
data: { body: bodyMessage, labels },
data: {
body: bodyMessage,
labels,
author_association,
user: { login },
},
} = await octokit.request('GET /repos/{owner}/{repo}/pulls/{pull_number}', {
owner: GIT_ORGANIZATION,
repo: GIT_REPO,
pull_number: Number(searchPullRequestId[1]),
});

switch (author_association) {
case 'CONTRIBUTOR':
community.contributors.add(`@${login}`);
break;
case 'FIRST_TIMER':
community.firstTimers.add(`@${login}`);
break;
case 'MEMBER':
community.team.add(`@${login}`);
break;
default:
}

prsLabelsMap[commitsItem.sha] = labels;

if (!bodyMessage) {
Expand Down Expand Up @@ -264,6 +287,27 @@ async function main(argv) {
year: 'numeric',
});

const logCommunitySection = () => {
// TODO: separate first timers and regular contributors
const contributors = [
...Array.from(community.contributors),
...Array.from(community.firstTimers),
].sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()));
if (contributors.length === 0) {
return '';
}

return `Special thanks go out to our community contributors who have helped make this release possible:\n${contributors.join(', ')}.`;
};

const logTeamSection = () => {
return `Following are all team members who have contributed to this release:\n${Array.from(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we need this? 🤔

By the way, WDYT about moving this to the top and replacing this existing somewhat pointless sentence:

We'd like to offer a big thanks to the ${authors.length} contributors who made this release possible. Here are some highlights ✨

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we need this? 🤔

I am trying to align this with the approach the core team is taking and since they are currently listing all contributors (but will apply this change to their repo as well) they want to keep all mentions. Right @mnajdova?

By the way, WDYT about moving this to the top and replacing this existing somewhat pointless sentence:

I thought about this as well. Might be worth a shot. We can always move it back if we think this looks odd or misplaced. 👍🏼

community.team,
)
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
.join(', ')}.`;
};

const changelog = `
## __VERSION__
<!-- generated comparing ${lastRelease}..${release} -->
Expand All @@ -275,6 +319,8 @@ We'd like to offer a big thanks to the ${

TODO INSERT HIGHLIGHTS
${changeLogMessages.length > 0 ? '\n\n' : ''}${changeLogMessages.join('\n')}
${logCommunitySection()}
${logTeamSection()}

<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->

Expand Down