Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for title option #189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BrunnerLivio
Copy link

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))

@BrunnerLivio
Copy link
Author

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}}
      {{~@root.host}}/
    {{~/if}}
    {{~#if @root.owner}}
      {{~@root.owner}}/
    {{~/if}}
    {{~@root.repository}}
  {{~else}}
    {{~@root.repoUrl}}
  {{~/if~}}
  /compare/{{previousTag}}...{{currentTag}})
{{~else}}
  {{~version}}
{{~/if}}
 ${title}
{{~#if date}} ({{date}})
{{/if}}`
        }
      },
    ],
...
  ],
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant