Skip to content

Commit

Permalink
ci: adjust release page generation
Browse files Browse the repository at this point in the history
This change is a POC to address JoshuaKGoldberg/create-typescript-app#1913.  Since it's not something we can really test locally, I figured we test it out here, and then, if successful, I can make the updates upstream.

Here we've changed the release-it config from json to js, which allows us to create a custom function for `github.releaseNotes`.  Using the context provided by release-it, we can filter by groups that we want to keep, and organize them into the same groups that we're organizing for the CHANGELOG (via conventional-changelog)
  • Loading branch information
michaelfaith committed Jan 25, 2025
1 parent 62f5813 commit 5d2cf5c
Showing 1 changed file with 57 additions and 27 deletions.
84 changes: 57 additions & 27 deletions .release-it.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,60 @@
{
"git": {
"commitMessage": "chore: release v${version}",
"requireCommits": true
module.exports = {
git: {
commitMessage: "chore: release v${version}",
requireCommits: true,
},
"github": {
"autoGenerate": true,
"release": true,
"releaseName": "v${version}"
github: {
release: true,
releaseName: "v${version}",
releaseNotes(context) {
const groupTitles = {
feat: "Features",
fix: "Bug Fixes",
perf: "Performance Improvements",
};
const commits = context.changelog.split("\n").slice(1);
const groups = Object.groupBy(commits, (commit) => {
// If it matches one of the types we care to show, then add the
// commit to that group.
for (const type in groupTitles) {
const regex = new RegExp(`^\s*[-*]?\s*${type}[(:]`);
if (regex.test(commit)) {
return type;
}
}

// If it didn't match any of the important groups, then add it to other
return "other";
});

// Use the data we've collected to build the release notes.
const releaseNotes = [];
for (const type in groupTitles) {
if (groups[type]) {
releaseNotes.push(`### ${groupTitles[type]}`);
releaseNotes.push(...groups[type]);
}
}
return releaseNotes.join("\n");
},
},
"npm": { "publishArgs": ["--access public", "--provenance"] },
"plugins": {
npm: { publishArgs: ["--access public", "--provenance"] },
plugins: {
"@release-it/conventional-changelog": {
"infile": "CHANGELOG.md",
"preset": "angular",
"types": [
{ "section": "Features", "type": "feat" },
{ "section": "Bug Fixes", "type": "fix" },
{ "section": "Performance Improvements", "type": "perf" },
{ "hidden": true, "type": "build" },
{ "hidden": true, "type": "chore" },
{ "hidden": true, "type": "ci" },
{ "hidden": true, "type": "docs" },
{ "hidden": true, "type": "refactor" },
{ "hidden": true, "type": "style" },
{ "hidden": true, "type": "test" }
]
}
}
}
infile: "CHANGELOG.md",
preset: "angular",
types: [
{ section: "Features", type: "feat" },
{ section: "Bug Fixes", type: "fix" },
{ section: "Performance Improvements", type: "perf" },
{ hidden: true, type: "build" },
{ hidden: true, type: "chore" },
{ hidden: true, type: "ci" },
{ hidden: true, type: "docs" },
{ hidden: true, type: "refactor" },
{ hidden: true, type: "style" },
{ hidden: true, type: "test" },
],
},
},
};

0 comments on commit 5d2cf5c

Please sign in to comment.