feat: implement custom semantic release configuration with enhanced changelog and comments#51
feat: implement custom semantic release configuration with enhanced changelog and comments#51
Conversation
Co-authored-by: pawcoding <[email protected]>
.github/semantic-release.md
Outdated
| **For Pre-releases:** | ||
|
|
||
| ``` | ||
| 🎉 This issue is included in version X.X.X-next.X which is now available for testing! 🚀 |
There was a problem hiding this comment.
| 🎉 This issue is included in version X.X.X-next.X which is now available for testing! 🚀 | |
| 🎉 This issue is included in version X.X.X-next.X which is now available for testing! 🧪 |
There was a problem hiding this comment.
Updated the documentation with the suggested change. The issue comment template now uses the test tube emoji (🧪) instead of rocket emoji. Commit: b4b4a0b
.github/semantic-release.md
Outdated
| 📦 NPM: [email protected] | ||
| 📖 GitHub Release: X.X.X-next.X | ||
|
|
||
| @username Would you mind testing this fix in your project and letting us know if it works as expected? We'd love your feedback! |
There was a problem hiding this comment.
| @username Would you mind testing this fix in your project and letting us know if it works as expected? We'd love your feedback! | |
| @username Can you check if everything works as expected in your project with this new version? Any feedback is welcome. |
There was a problem hiding this comment.
Updated the documentation with the suggested wording change for asking users to test the fix. Commit: b4b4a0b
.github/semantic-release.md
Outdated
|
|
||
| @username Would you mind testing this fix in your project and letting us know if it works as expected? We'd love your feedback! | ||
|
|
||
| This change will be included in the next regular release. |
There was a problem hiding this comment.
| This change will be included in the next regular release. | |
| <small>This change will be included in the next regular release.</small> |
There was a problem hiding this comment.
Updated the documentation to use <small> tags around the "This change will be included in the next regular release" text. Commit: b4b4a0b
.github/semantic-release.md
Outdated
| **For Pre-releases:** | ||
|
|
||
| ``` | ||
| 🎉 This PR is included in version X.X.X-next.X which is now available for testing! 🚀 |
There was a problem hiding this comment.
| 🎉 This PR is included in version X.X.X-next.X which is now available for testing! 🚀 | |
| 🎉 This PR is included in version X.X.X-next.X which is now available for testing! 🧪 |
There was a problem hiding this comment.
Updated the documentation with the suggested change. The PR comment template now uses the test tube emoji (🧪) instead of rocket emoji. Commit: b4b4a0b
.github/semantic-release.md
Outdated
| 📦 NPM: [email protected] | ||
| 📖 GitHub Release: X.X.X-next.X | ||
|
|
||
| @username Thank you for your contribution! This PR |
There was a problem hiding this comment.
| @username Thank you for your contribution! This PR | |
| @username Thank you for your contribution! |
There was a problem hiding this comment.
Updated the documentation with the cleaner PR comment template. Commit: b4b4a0b
There was a problem hiding this comment.
Just from looking at these templates I cannot quite imagine how a changelog entry would look. Can you create an example for this PR: #48
release.config.cjs
Outdated
| successComment: `<% if (nextRelease.channel) { %>:tada: This <%= issue.pull_request ? 'PR' : 'issue' %> is included in version <%= nextRelease.version %> which is now available for testing! :rocket: | ||
|
|
||
| 📦 **NPM:** [\`<%= package.name %>@<%= nextRelease.version %>\`](https://www.npmjs.com/package/<%= package.name %>/v/<%= nextRelease.version %>) | ||
| 📖 **GitHub Release:** [<%= nextRelease.version %>](<%= releases[0].url %>) | ||
|
|
||
| <%= issue.pull_request ? '@' + issue.pull_request.user.login : '@' + issue.user.login %> <%= issue.pull_request ? 'Thank you for your contribution! This PR' : 'Would you mind testing this fix in your project and letting us know if it works as expected? We\\'d love your feedback!' %> | ||
|
|
||
| This change will be included in the next regular release.<% } else { %>:tada: This <%= issue.pull_request ? 'PR' : 'issue' %> is included in version <%= nextRelease.version %> which is now available! :rocket: | ||
|
|
||
| 📦 **NPM:** [\`<%= package.name %>@<%= nextRelease.version %>\`](https://www.npmjs.com/package/<%= package.name %>/v/<%= nextRelease.version %>) | ||
| 📖 **GitHub Release:** [<%= nextRelease.version %>](<%= releases[0].url %>)<%= issue.pull_request ? '\\n\\nThank you for your contribution!' : '' %><% } %>`, |
There was a problem hiding this comment.
Please adjust the comment with the above mentioned changes in the documentation.
There was a problem hiding this comment.
Updated the GitHub comment templates in the release config to match the documentation changes, using test tube emoji and the improved wording. Commit: b4b4a0b
release.config.cjs
Outdated
|
|
||
| 📦 **NPM:** [\`<%= package.name %>@<%= nextRelease.version %>\`](https://www.npmjs.com/package/<%= package.name %>/v/<%= nextRelease.version %>) | ||
| 📖 **GitHub Release:** [<%= nextRelease.version %>](<%= releases[0].url %>)<%= issue.pull_request ? '\\n\\nThank you for your contribution!' : '' %><% } %>`, | ||
| releasedLabels: ["released on @<%= nextRelease.channel || 'latest' %>"], |
There was a problem hiding this comment.
I don't think this is needed. The default label is fine.
There was a problem hiding this comment.
Removed the releasedLabels configuration option since the default label is sufficient. Commit: b4b4a0b
release.config.cjs
Outdated
| 📦 **NPM:** [\`<%= package.name %>@<%= nextRelease.version %>\`](https://www.npmjs.com/package/<%= package.name %>/v/<%= nextRelease.version %>) | ||
| 📖 **GitHub Release:** [<%= nextRelease.version %>](<%= releases[0].url %>)<%= issue.pull_request ? '\\n\\nThank you for your contribution!' : '' %><% } %>`, | ||
| releasedLabels: ["released on @<%= nextRelease.channel || 'latest' %>"], | ||
| addReleases: "bottom" |
There was a problem hiding this comment.
What does this option do? Not sure if it's needed.
There was a problem hiding this comment.
Removed the addReleases configuration option as it wasn't necessary for our use case. Commit: b4b4a0b
release.config.cjs
Outdated
| transform: (commit, context) => { | ||
| const issues = []; | ||
|
|
||
| commit.notes.forEach((note) => { | ||
| note.title = "BREAKING CHANGES"; | ||
| }); | ||
|
|
||
| // Group different commit types under appropriate categories | ||
| if (commit.type === "feat") { | ||
| commit.type = "Features"; | ||
| } else if (commit.type === "fix") { | ||
| commit.type = "Bug Fixes"; | ||
| } else if (commit.type === "docs") { | ||
| commit.type = "Documentation"; | ||
| } else if ( | ||
| ["style", "refactor", "test", "build", "ci", "chore"].includes( | ||
| commit.type | ||
| ) | ||
| ) { | ||
| commit.type = "Internals"; | ||
| } else if (commit.type === "perf") { | ||
| commit.type = "Performance Improvements"; | ||
| } else if (commit.revert) { | ||
| commit.type = "Reverts"; | ||
| } else { | ||
| return; | ||
| } | ||
|
|
||
| if (commit.scope === "*") { | ||
| commit.scope = ""; | ||
| } | ||
|
|
||
| if (typeof commit.hash === "string") { | ||
| commit.shortHash = commit.hash.substring(0, 7); | ||
| } | ||
|
|
||
| if (typeof commit.subject === "string") { | ||
| let url = context.repository | ||
| ? `${context.host}/${context.owner}/${context.repository}` | ||
| : context.repoUrl; | ||
| if (url) { | ||
| url = `${url}/issues/`; | ||
| // Issue URLs. | ||
| commit.subject = commit.subject.replace( | ||
| /#([0-9]+)/g, | ||
| (_, issue) => { | ||
| issues.push(issue); | ||
| return `[#${issue}](${url}${issue})`; | ||
| } | ||
| ); | ||
| } | ||
| if (context.host) { | ||
| // User URLs. | ||
| commit.subject = commit.subject.replace( | ||
| /\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, | ||
| (_, username) => { | ||
| if (username.includes("/")) { | ||
| return `@${username}`; | ||
| } | ||
|
|
||
| return `[@${username}](${context.host}/${username})`; | ||
| } | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| // remove references that already appear in the subject | ||
| commit.references = commit.references.filter((reference) => { | ||
| if (issues.indexOf(reference.issue) === -1) { | ||
| return true; | ||
| } | ||
|
|
||
| return false; | ||
| }); | ||
|
|
||
| return commit; | ||
| } |
There was a problem hiding this comment.
Can you extract this function into a separate utility script 😅
The config itself is already hard to read without it
There was a problem hiding this comment.
Extracted the large transform function into a separate utility script at .semantic-release/utils/transform-commit.js to improve readability of the main configuration file. The config file is now much cleaner and easier to understand. Commit: b4b4a0b
…iguration Co-authored-by: pawcoding <[email protected]>
This PR implements a comprehensive custom semantic release configuration that enhances the changelog generation and GitHub interaction experience as requested in the issue.
Key Changes
📖 Enhanced Changelog with Emojis
The changelog now automatically categorizes commits with descriptive emojis and includes contributor information:
featcommits)fixcommits)docscommits)refactor,style,test,build,ci,chorecommits)perfcommits)Each commit entry now includes contributor attribution showing
@usernamefor proper credit.💬 Personalized GitHub Comments
Issue Comments:
PR Comments:
All comments include NPM package links and GitHub release links for easy access.
🏗️ Implementation Details
The implementation uses custom Handlebars templates in
.semantic-release/templates/to control the changelog formatting. The main configuration inrelease.config.cjshas been enhanced with:📚 Documentation
Added comprehensive documentation in
.github/semantic-release.mdexplaining:The implementation maintains full backward compatibility with the existing workflow while providing the enhanced experience requested.
Fixes #50.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.