-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
62f5813
commit 5d2cf5c
Showing
1 changed file
with
57 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" }, | ||
], | ||
}, | ||
}, | ||
}; |