Skip to content

Latest commit

 

History

History
74 lines (61 loc) · 2.21 KB

auto-changelog.md

File metadata and controls

74 lines (61 loc) · 2.21 KB

Auto-changelog

Please refer to auto-changelog documentation for more details and usage.

Config

Add auto-changelog to the project:

npm install --save-dev auto-changelog

Example configuration in the release-it config:

{
  "git": {
    "changelog": "npx auto-changelog --stdout --commit-limit false --unreleased --template https://raw.githubusercontent.com/release-it/release-it/main/templates/changelog-compact.hbs"
  },
  "hooks": {
    "after:bump": "npx auto-changelog -p"
  }
}

Template

This is basically a copy of the default auto-changelog template. However, the title is removed, and the releases iterator has a {{#if @first}} block to only show commits within the unreleased tag:

{{#each releases}}
  {{#if @first}}
    {{#each merges}}
      - {{{message}}}{{#if href}} [`#{{id}}`]({{href}}){{/if}}
    {{/each}}
    {{#each fixes}}
      - {{{commit.subject}}}{{#each fixes}}{{#if href}} [`#{{id}}`]({{href}}){{/if}}{{/each}}
    {{/each}}
    {{#each commits}}
      - {{#if breaking}}**Breaking change:** {{/if}}{{{subject}}}{{#if href}} [`{{shorthash}}`]({{href}}){{/if}}
    {{/each}}
  {{/if}}
{{/each}}

The template above changelog-compact.hbs can also be used directly from here:

{
  "git": {
    "changelog": "npx auto-changelog --stdout --commit-limit false --unreleased --template https://raw.githubusercontent.com/release-it/release-it/main/templates/changelog-compact.hbs"
  },
  "hooks": {
    "after:bump": "npx auto-changelog -p"
  }
}

Projects without a package.json that need to generate a CHANGELOG.md compatible with https://keepachangelog.com can use this example:

{
  "git": {
    "changelog": "npx auto-changelog --stdout --commit-limit false --unreleased --template https://raw.githubusercontent.com/release-it/release-it/main/templates/changelog-compact.hbs"
  },
  "hooks": {
    "after:bump": "npx auto-changelog --commit-limit false --template https://raw.githubusercontent.com/release-it/release-it/main/templates/keepachangelog.hbs"
  }
}