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

Update release note format #82

Merged
merged 7 commits into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions __mocks__/@actions/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,132 +42,151 @@ const PRs = [
number: 500,
merged_at: null,
base: { ref: 'develop' },
user: { login: 'adamrusted' },
},
{
// 1: PR that adds a file
title: '501',
number: 501,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'LitoMore' },
},
{
// 2: PR that modifies an SVG
title: '502',
number: 502,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'mondeja' },
},
{
// 3: PR that was merged before the previous release
title: '498',
number: 498,
merged_at: '2011-01-01T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'PeterShaggyNoble' },
},
{
// 4: PR that modifies one icon's color
title: '503',
number: 503,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'service-paradis' },
},
{
// 5: PR that modifies one icon's source
title: '504',
number: 504,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'fbernhart' },
},
{
// 6: PR that modifies one icon's color and source
title: '505',
number: 505,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'adamrusted' },
},
{
// 7: PR that modifies an SVG and modifies that icon's color
title: '506',
number: 506,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'LitoMore' },
},
{
// 8: PR that modifies an SVG and modifies that icon's source
title: '507',
number: 507,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'mondeja' },
},
{
// 9: PR that modifies an SVG and modifies that icon's color and source
title: '508',
number: 508,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'PeterShaggyNoble' },
},
{
// 10: PR that adds an SVG and modifies another icon's color and source
title: '509',
number: 509,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'service-paradis' },
},
{
// 11: PR that adds an SVG and modifies another SVG
title: '510',
number: 510,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'fbernhart' },
},
{
// 12: PR that changes the data file but no metadata
title: '511',
number: 511,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'adamrusted' },
},
{
// 13: PR that adds a brand with a lowercased name
title: '512',
number: 512,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'LitoMore' },
},
{
// 14: PR that adds ACM (which should be listed before the lowercased brand)
title: '513',
number: 513,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'mondeja' },
},
{
// 15: PR that adds a brand with an accented name
title: '514',
number: 514,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'PeterShaggyNoble' },
},
{
// 16: PR that removes an icon
title: '515',
number: 515,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'develop' },
user: { login: 'service-paradis' },
},
{
// Skipped release
title: '[skip] Skip this one',
number: 516,
merged_at: '2011-01-26T19:01:12Z',
base: { ref: 'master' },
user: { login: 'fbernhart' },
},
{
// Previous release
title: 'Release',
number: 499,
merged_at: '2011-01-02T19:01:12Z',
base: { ref: 'master' },
user: { login: 'LitoMore' },
},
];

Expand Down
2 changes: 1 addition & 1 deletion lib/index.mjs

Large diffs are not rendered by default.

26 changes: 20 additions & 6 deletions src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ function prNumbersToString(prNumbers) {
return prNumbers.map((prNumber) => `#${prNumber}`).join(', ');
}

function authorsToString(authors) {
return authors.map((author) => `@${author}`).join(', ');
}

// GitHub API
async function addLabels(client, context, issueNumber, labels) {
await client.rest.issues.addLabels({
Expand Down Expand Up @@ -249,6 +253,7 @@ async function getFilesSinceLastRelease(core, client, context) {
for (let file of await getPrFiles(core, client, context, pr.number)) {
core.info(`found '${file.path}' in PR #${pr.number}`);
file.prNumber = pr.number;
file.author = pr.user.login;
file.merged_at = pr.merged_at;
files.push(file);
}
Expand Down Expand Up @@ -276,6 +281,7 @@ async function getChangesFromFile(core, file, client, context, id) {
name: he.decode(svgTitleMatch[1]),
path: file.path,
prNumbers: [file.prNumber],
authors: [file.author],
},
];
} else if (isIconFile(file.path) && file.status === STATUS_MODIFIED) {
Expand All @@ -290,6 +296,7 @@ async function getChangesFromFile(core, file, client, context, id) {
name: he.decode(svgTitleMatch[1]),
path: file.path,
prNumbers: [file.prNumber],
authors: [file.author],
},
];
} else if (isIconFile(file.path) && file.status === STATUS_REMOVED) {
Expand All @@ -303,16 +310,14 @@ async function getChangesFromFile(core, file, client, context, id) {
name: he.decode(svgTitleMatch[1]),
path: file.path,
prNumbers: [file.prNumber],
authors: [file.author],
},
];
} else if (isSimpleIconsDataFile(file.path)) {
core.info(`Detected a change to the data file`);
const changes = [];

let filePatch = file.patch;
core.debug(`\nSimple Icons data file`);
core.debug(file);

if (!filePatch) {
const contentResult = await client.rest.repos.getContent({
owner: context.repo.owner,
Expand All @@ -337,6 +342,7 @@ async function getChangesFromFile(core, file, client, context, id) {
changeType: CHANGE_TYPE_UPDATE,
name: name,
prNumbers: [file.prNumber],
authors: [file.author],
});
}

Expand All @@ -358,6 +364,7 @@ function filterDuplicates(newIcons, updatedIcons, removedIcons) {
for (let updatedIcon of updatedIcons) {
if (updatedIcon.name === newIcon.name) {
newIcon.prNumbers.push(...updatedIcon.prNumbers);
newIcons.authors.push(...updatedIcon.authors);
removeFromUpdated.push(updatedIcon);
}
}
Expand Down Expand Up @@ -411,7 +418,11 @@ function filterDuplicates(newIcons, updatedIcons, removedIcons) {
const otherPrNumbers = otherIcon.prNumbers.filter(
(prNumber) => !updatedIcon.prNumbers.includes(prNumber),
);
const otherAuthors = otherIcon.authors.filter(
(author) => !updatedIcon.authors.includes(author),
);
updatedIcon.prNumbers.push(...otherPrNumbers);
updatedIcon.authors.push(...otherAuthors);
removeFromUpdated.push(otherIcon);
}
}
Expand Down Expand Up @@ -489,23 +500,26 @@ function createReleaseNotes(newVersion, newIcons, updatedIcons, removedIcons) {
releaseNotes += '\n# New Icons\n\n';
for (let newIcon of newIcons.sort(sortAlphabetically)) {
const prs = prNumbersToString(newIcon.prNumbers);
releaseNotes += `- ${newIcon.name} (${prs})\n`;
const authors = authorsToString(newIcon.authors);
releaseNotes += `- ${newIcon.name} (${prs}) (${authors})\n`;
}
}

if (updatedIcons.length > 0) {
releaseNotes += '\n# Updated Icons\n\n';
for (let updatedIcon of updatedIcons.sort(sortAlphabetically)) {
const prs = prNumbersToString(updatedIcon.prNumbers);
releaseNotes += `- ${updatedIcon.name} (${prs})\n`;
const authors = authorsToString(updatedIcon.authors);
releaseNotes += `- ${updatedIcon.name} (${prs}) (${authors})\n`;
}
}

if (removedIcons.length > 0) {
releaseNotes += '\n# Removed Icons\n\n';
for (let removedIcon of removedIcons.sort(sortAlphabetically)) {
const prs = prNumbersToString(removedIcon.prNumbers);
releaseNotes += `- ${removedIcon.name} (${prs})\n`;
const authors = authorsToString(removedIcon.authors);
releaseNotes += `- ${removedIcon.name} (${prs}) (${authors})\n`;
}
}

Expand Down
32 changes: 16 additions & 16 deletions test/create.test.js
LitoMore marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ The new version will be: **v2.0.0**

# New Icons

- ACM (#513)
- bar (#512)
- Foo (#501)
- Jest (#509)
- Pokémon (#514)
- WordPress (#510)
- ACM (#513) (@mondeja)
- bar (#512) (@LitoMore)
- Foo (#501) (@LitoMore)
- Jest (#509) (@service-paradis)
- Pokémon (#514) (@PeterShaggyNoble)
- WordPress (#510) (@fbernhart)

# Updated Icons

- 1Password (#503)
- Abstract (#509)
- AddThis (#508)
- Adobe (#504)
- Feedly (#502)
- Intel (#507)
- Mozilla (#505)
- Opera (#510)
- Postman (#506)
- 1Password (#503) (@service-paradis)
- Abstract (#509) (@service-paradis)
- AddThis (#508) (@PeterShaggyNoble)
- Adobe (#504) (@fbernhart)
- Feedly (#502) (@mondeja)
- Intel (#507) (@mondeja)
- Mozilla (#505) (@adamrusted)
- Opera (#510) (@fbernhart)
- Postman (#506) (@LitoMore)

# Removed Icons

- Foobar (#515)
- Foobar (#515) (@service-paradis)
`;

beforeEach(() => {
Expand Down