Skip to content

Commit dc22232

Browse files
authored
ci: release log for github (#1413)
### Description of Changes Parse & format changelogs for github release note ### Notes & Questions About Changes I couldn't really make the conventional changelog plugin work for the GitHub release note as we want - at this point, it might be better to use the plugin only to cover the version handling. ### Validation / Testing look at the test release I cut from this branch: https://github.com/NASA-IMPACT/veda-ui/releases (will delete it - and I tweaked the header not to be capitalized after)
1 parent 168a990 commit dc22232

File tree

4 files changed

+73
-36
lines changed

4 files changed

+73
-36
lines changed

.release-it.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
const prefixes = {
2+
feat: '🎉 Features',
3+
fix: '🐛 Fixes',
4+
docs: '🚀 Improvements',
5+
ci: '🚀 Improvements',
6+
test: '🚀 Improvements',
7+
refactor: '🚀 Improvements',
8+
chore: '🚀 Improvements',
9+
revert: '🐛 Fixes'
10+
};
11+
12+
function groupCommitsByCategory(logs) {
13+
const grouped = {};
14+
15+
// Initialize categories from the values in the prefixes dictionary
16+
Object.values(prefixes).forEach((category) => {
17+
grouped[category] = [];
18+
});
19+
20+
// Loop through each prefix to find conventional commit pattern ex. feat: , feat(card):
21+
Object.entries(prefixes).forEach(([prefix, category]) => {
22+
const regex = new RegExp(`^\\* ${prefix}(\\(.*?\\))?: .*?\\)$`, 'gm');
23+
const matches = logs.match(regex) || [];
24+
grouped[category] = [...matches, ...grouped[category]];
25+
});
26+
27+
return grouped;
28+
}
29+
30+
module.exports = {
31+
hooks: {
32+
'after:release': 'echo "VERSION_NUMBER=v${version}" >> "$GITHUB_OUTPUT" '
33+
},
34+
git: {
35+
commitMessage: 'chore(release): update to version v${version}',
36+
tagName: 'v${version}',
37+
tagAnnotation: 'Release v${version}',
38+
pushArgs: ['--follow-tags'],
39+
getLatestTagFromAllRefs: true
40+
},
41+
npm: {
42+
publish: false
43+
},
44+
github: {
45+
release: true,
46+
releaseName: 'v${version}',
47+
autoGenerate: false,
48+
releaseNotes: function (context) {
49+
const groupedCommits = groupCommitsByCategory(context.changelog);
50+
const changelog = Object.entries(groupedCommits)
51+
.map(([prefix, commits]) => {
52+
if (commits.length > 0) {
53+
return `## What's changed \n ### ${prefix}\n ${commits.join('\n')}`;
54+
}
55+
})
56+
.join('\n');
57+
58+
return changelog;
59+
}
60+
},
61+
plugins: {
62+
// The @release-it/conventional-changelog plugin is primarily used for handling version bumps
63+
// because we encountered difficulties generating GitHub release notes with the plugin.
64+
'@release-it/conventional-changelog': {
65+
preset: 'conventionalcommits'
66+
}
67+
}
68+
};

.release-it.json

Lines changed: 0 additions & 31 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"@parcel/transformer-typescript-types": "2.12.0",
6565
"@parcel/transformer-webmanifest": "2.7.0",
6666
"@playwright/test": "^1.46.1",
67-
"@release-it/conventional-changelog": "^9.0.3",
67+
"@release-it/conventional-changelog": "^10.0.0",
6868
"@testing-library/dom": "^10.4.0",
6969
"@testing-library/jest-dom": "^6.6.3",
7070
"@testing-library/react": "^16.1.0",

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3934,10 +3934,10 @@
39343934
"@babel/runtime" "^7.23.2"
39353935
immutable "^4.3.4"
39363936

3937-
"@release-it/conventional-changelog@^9.0.3":
3938-
version "9.0.3"
3939-
resolved "http://verdaccio.ds.io:4873/@release-it%2fconventional-changelog/-/conventional-changelog-9.0.3.tgz#4d8a4b07a7bba8c6ed151ea8ae75bca15d3219eb"
3940-
integrity sha512-+3TL+B89Kc+VTbfGxpTvJkbegWt5XIzkovsYVJyoZpOZDG07v25FU8c5R5Q8yNUs76Ikfq0sp+ZTTxmefG4Hiw==
3937+
"@release-it/conventional-changelog@^10.0.0":
3938+
version "10.0.0"
3939+
resolved "http://verdaccio.ds.io:4873/@release-it%2fconventional-changelog/-/conventional-changelog-10.0.0.tgz#25a9b4785d59ea1c2dce9acafc3c0cc86552826f"
3940+
integrity sha512-49qf9phGmPUIGpY2kwfgehs9en1znbPv2zdNn1WMLAH9DtHUh4m6KNSB+mLFGAMUhv24JhsA8ruYRYgluc2UJw==
39413941
dependencies:
39423942
concat-stream "^2.0.0"
39433943
conventional-changelog "^6.0.0"

0 commit comments

Comments
 (0)