release-notes-generator
release-notes-generator copied to clipboard
feat: add support for title option
Description
conventional-changelog-angular offers an optional configuration in the header.hbs for titles.
This pull request exposes this option.
Motivation
I wanted to have custom auto-generated titles in my release-notes so they're more memorable. I wanted to use Moniker in order to generate a random word, like so:
const Moniker = require("moniker");
const title = Moniker.generator([Moniker.adjective, Moniker.noun], { glue: ' ' }).choose();
console.log('Creating release: ' + title);
module.exports = {
plugins: [
"@semantic-release/commit-analyzer",
[
"@semantic-release/release-notes-generator",
{
preset: 'angular',
title,
},
],
...
],
};
... which results in:
# 1.2.0 (https://MY_DOMAIN.COM/compare/v1.1.0...v1.2.0) "barbarous flight" (2020-10-05)
### Bug Fixes
* add release titles (2d47e7f (https://MY_DOMAIN.COM/commit/2d47e7f3d3ac322cd25f7f24f8c28b202b4ae6bc))
### Features
* a new release (ffb348b (https://MY_DOMAIN.COM/commit/ffb348bc362fc8f1a741df6cc849c3120fa5cefd))
A workaround for this PR currently is by overwriting the default partial provided by whatever preset you are using. For example for Angular preset:
const Moniker = require("moniker");
const title = Moniker.generator([Moniker.adjective, Moniker.noun], { glue: ' ' }).choose();
module.exports = {
plugins: [
"@semantic-release/commit-analyzer",
[
"@semantic-release/release-notes-generator",
{
preset: 'angular',
writerOpts: {
headerPartial: `{{#if isPatch~}}
##
{{~else~}}
#
{{~/if}} {{#if @root.linkCompare~}}
[{{version}}](
{{~#if @root.repository~}}
{{~#if @root.host}}
{{[email protected]}}/
{{~/if}}
{{~#if @root.owner}}
{{[email protected]}}/
{{~/if}}
{{[email protected]}}
{{~else}}
{{[email protected]}}
{{~/if~}}
/compare/{{previousTag}}...{{currentTag}})
{{~else}}
{{~version}}
{{~/if}}
${title}
{{~#if date}} ({{date}})
{{/if}}`
}
},
],
...
],
};