Generate release notes with customized issue prefixes and URL format when using Semantic release

Kwinten
2 min readApr 23, 2021

When trying to generate release notes with semantic-release, it is assuming you are using the angular commit message format.

It expects your commit messages are using # as the issue prefix format and referencing the issue URL ${YOUR_REPO_BASE_URL}/issues/${ISSUE_NUMBER_AFTER '#'}

So as an example, if you have Fix #12 in your commit message. Your release note would generate a link like this

Fix #12.

In case you are using Azure DevOps or Jira for issue tracking, you can customize the semantic release config as below:

Steps

  1. Create a .releaserc in the project root directory
  2. Put in below content
{
"plugins": [
["@semantic-release/commit-analyzer", {
"preset": "conventionalcommits"
}],
["@semantic-release/release-notes-generator", {
"preset": "conventionalcommits",
"presetConfig": {
"issuePrefixes": ['AB#'],
"issueUrlFormat": 'https://dev.azure.com/${REPLACE_WITH_ORGANIZATION_NAME}/${REPLACE_WITH_PROJECT_NAME}/_workitems/edit/{{id}}'
}
}],
"@semantic-release/npm",
"@semantic-release/github",
]
}

The above is an example for Azure DevOps, in case you have a different issue prefix and URL, update the issuePrefixes and issueUrlFormat under presetConfig

Important Note: be aware that it is a must to use "preset": "conventionalcommits" instead if "preset": "angular", check out the issue here

Happy Automation!

This article originally posted on my personal blog where I shared different topics including Node.js, Cloud computing, and other interesting stuff.

Cross-posted from https://blog.imkwinten.com/article/Generate-release-notes-with-customized-issue-prefixes-and-url-format-when-using-Semantic-release.

--

--