Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

auto-changelog

CookPete504.8kMIT2.5.0

Command line tool for generating a changelog from git tags and commit history

auto, automatic, changelog, change, log, generator, git, commit, commits, history

readme

auto-changelog

Command line tool for generating a changelog from git tags and commit history. Used by Modernizr, Netlify, Neutrino and Velocity.js.

Latest npm version Build Status Test Coverage

Installation

npm install -g auto-changelog

Usage

Simply run auto-changelog in the root folder of a git repository. git log is run behind the scenes in order to parse the commit history.

Usage: auto-changelog [options]

Options:

  -o, --output [file]                 # output file, default: CHANGELOG.md
  -c, --config [file]                 # config file location, default: .auto-changelog
  -t, --template [template]           # specify template to use [compact, keepachangelog, json], default: compact
  -r, --remote [remote]               # specify git remote to use for links, default: origin
  -p, --package                       # use version from package.json as latest release
  -v, --latest-version [version]      # use specified version as latest release
  -u, --unreleased                    # include section for unreleased changes
  -l, --commit-limit [count]          # number of commits to display per release, default: 3
  -b, --backfill-limit [count]        # number of commits to backfill empty releases with, default: 3
      --commit-url [url]              # override url for commits, use {id} for commit id
      --issue-url [url]               # override url for issues, use {id} for issue id
      --merge-url [url]               # override url for merges, use {id} for merge id
      --compare-url [url]             # override url for compares, use {from} and {to} for tags
      --issue-pattern [regex]         # override regex pattern for issues in commit messages
      --breaking-pattern [regex]      # regex pattern for breaking change commits
      --merge-pattern [regex]         # add custom regex pattern for merge commits
      --commit-pattern [regex]        # pattern to include when parsing commits
      --ignore-commit-pattern [regex] # pattern to ignore when parsing commits
      --tag-pattern [regex]           # override regex pattern for version tags
      --tag-prefix [prefix]           # prefix used in version tags, default: v
      --starting-version [tag]        # specify earliest version to include in changelog
      --starting-date [yyyy-mm-dd]    # specify earliest date to include in changelog
      --ending-version [tag]          # specify latest version to include in changelog
      --sort-commits [property]       # sort commits by property [relevance, date, date-desc, subject, subject-desc], default: relevance
      --release-summary               # display tagged commit message body as release summary
      --unreleased-only               # only output unreleased changes
      --hide-empty-releases           # hide empty releases
      --hide-credit                   # hide auto-changelog credit
      --handlebars-setup [file]       # handlebars setup file
      --append-git-log [string]       # string to append to git log command
      --append-git-tag [string]       # string to append to git tag command
      --prepend                       # prepend changelog to output file
      --stdout                        # output changelog to stdout
      --plugins [...name]             # use plugins to augment commit/merge/release information
  -V, --version                       # output the version number
  -h, --help                          # output usage information


# Write log to CHANGELOG.md in current directory
auto-changelog

# Write log to HISTORY.md using keepachangelog template
auto-changelog --output HISTORY.md --template keepachangelog

# Disable the commit limit, rendering all commits for every release
auto-changelog --commit-limit false

Requirements

auto-changelog is designed to be as flexible as possible, providing a clear changelog for any project. There are only two absolute requirements:

  • You should be using git 1.7.2 or later
  • All versions should be tagged using semver tag names – this happens by default when using npm version

There are some less strict requirements to improve your changelog:

What you might do if you’re clever

Install auto-changelog to dev dependencies:

npm install auto-changelog --save-dev
# or
yarn add auto-changelog --dev

Add auto-changelog -p && git add CHANGELOG.md to the version scripts in your package.json:

{
  "name": "my-awesome-package",
  "version": "1.0.0",
  "devDependencies": {
    "auto-changelog": "*"
  },
  "scripts": {
    "version": "auto-changelog -p && git add CHANGELOG.md"
  }
}

Using -p or --package uses the version from package.json as the latest release, so that all commits between the previous release and now become part of that release. Essentially anything that would normally be parsed as Unreleased will now come under the version from package.json

Now every time you run npm version, the changelog will automatically update and be part of the version commit.

Advanced Usage

URL Overrides

Links to commits, issues, pull requests and version diffs are automatically generated based on your remote URL. GitHub, GitLab, BitBucket and Azure DevOps are all supported. If you have an unusual remote or need to override one of the link formats, use --commit-url, --issue-url or --merge-url with an {id} token. For custom version diffs, use --compare-url with {from} and {to} tokens.

# Link all issues to redmine
auto-changelog --issue-url https://www.redmine.org/issues/{id}

# Link to custom diff page
auto-changelog --compare-url https://example.com/repo/compare/{from}...{to}

Add to an existing changelog

If you’d like to keep an existing changelog below your generated one, just add <!-- auto-changelog-above --> to your current changelog. The generated changelog will be added above this token, and anything below will remain.

Configuration

You can set any option in package.json under the auto-changelog key, using camelCase options.

{
  "name": "my-awesome-package",
  "version": "1.0.0",
  "scripts": {
    // ...
  },
  "auto-changelog": {
    "output": "HISTORY.md",
    "template": "keepachangelog",
    "unreleased": true,
    "commitLimit": false
  }
}

You can also store config options in an .auto-changelog file in your project root:

{
  "output": "HISTORY.md",
  "template": "keepachangelog",
  "unreleased": true,
  "commitLimit": false
}

Note that any options set in package.json will take precedence over any set in .auto-changelog.

Tag prefixes

Use --tag-prefix [prefix] if you prefix your version tags with a certain string:

# When all versions are tagged like my-package/1.2.3
auto-changelog --tag-prefix my-package/

Tag patterns

By default, auto-changelog looks for valid semver tags to build a list of releases. If you are using another format (or want to include all tags), use --tag-pattern [regex]:

# When all versions are tagged like build-12345
auto-changelog --tag-pattern build-\d+

# Include any tag as a release
auto-changelog --tag-pattern .+

Breaking changes

If you use a common pattern in your commit messages for breaking changes, use --breaking-pattern to highlight those commits as breaking changes in your changelog. Breaking change commits will always be listed as part of a release, regardless of any --commit-limit set.

auto-changelog --breaking-pattern "BREAKING CHANGE:"

Custom issue patterns

By default, auto-changelog will parse GitHub-style issue fixes in your commit messages. If you use Jira or an alternative pattern in your commits to reference issues, you can pass in a custom regular expression to --issue-pattern along with --issue-url:

# Parse Jira-style issues in your commit messages, like PROJECT-418
auto-changelog --issue-pattern [A-Z]+-\d+ --issue-url https://issues.apache.org/jira/browse/{id}

Or, in your package.json:

{
  "name": "my-awesome-package",
  "auto-changelog": {
    "issueUrl": "https://issues.apache.org/jira/browse/{id}",
    "issuePattern": "[A-Z]+-\d+"
  }
}

If you use a certain pattern before or after the issue number, like fixes {id}, just use a capturing group:

# "This commit fixes ISSUE-123" will now parse ISSUE-123 as an issue fix
auto-changelog --issue-pattern "[Ff]ixes ([A-Z]+-\d+)"

Custom templates

If you aren’t happy with the default templates or want to tweak something, you can point to a handlebars template in your local repo. Check out the existing templates to see what is possible.

Save changelog-template.hbs somewhere in your repo:

### Changelog
My custom changelog template. Don’t worry about indentation here; it is automatically removed from the output.

{{#each releases}}
  Every release has a {{title}} and a {{href}} you can use to link to the commit diff.
  It also has an {{isoDate}} and a {{niceDate}} you might want to use.
  {{#each merges}}
    - A merge has a {{message}}, an {{id}} and a {{href}} to the PR.
  {{/each}}
  {{#each fixes}}
    - Each fix has a {{commit}} with a {{commit.subject}}, an {{id}} and a {{href}} to the fixed issue.
  {{/each}}
  {{#each commits}}
    - Commits have a {{shorthash}}, a {{subject}} and a {{href}}, {{author}} amongst other things.
  {{/each}}
{{/each}}

Then just use --template to point to your template:

auto-changelog --template changelog-template.hbs

You can also point to an external template by passing in a URL:

auto-changelog --template https://example.com/templates/compact.hbs

To see exactly what data is passed in to the templates, you can generate a JSON version of the changelog:

auto-changelog --template json --output changelog-data.json

commit-list helper

Use {{#commit-list}} to render a list of commits depending on certain patterns in the commit messages:

{{#each releases}}
  ### [{{title}}]({{href}})

  {{! List commits with `Breaking change: ` somewhere in the message }}
  {{#commit-list commits heading='### Breaking Changes' message='Breaking change: '}}
    - {{subject}} [`{{shorthash}}`]({{href}})
  {{/commit-list}}

  {{! List commits that add new features, but not those already listed above }}
  {{#commit-list commits heading='### New Features' message='feat: ' exclude='Breaking change: '}}
    - {{subject}} [`{{shorthash}}`]({{href}})
  {{/commit-list}}
{{/each}}
Option Description
heading A heading for the list, only renders if at least one commit matches
message A regex pattern to match against the entire commit message
subject A regex pattern to match against the commit subject only
exclude A regex pattern to exclude from the list – useful for avoiding listing commits more than once

Replacing text

To insert links or other markup to PR titles and commit messages that appear in the log, use the replaceText option in your package.json:

{
  "name": "my-awesome-package",
  "auto-changelog": {
    "replaceText": {
      "(ABC-\\d+)": "[`$1`](https://issues.apache.org/jira/browse/$1)"
    }
  }
}

Here, any time a pattern like ABC-123 appears in your log, it will be replaced with a link to the relevant issue in Jira. Each pattern is applied using string.replace(new RegExp(key, 'g'), value).

Handlebars setup file

The --handlebars-setup options allows you to point to a file to add custom Handlebars helpers, for use in custom templates using --template. Paths are relative to the directory in which you run auto-changelog.

auto-changelog --handlebars-setup setup.js --template custom-template.hbs

// setup.js
module.exports = function (Handlebars) {
  Handlebars.registerHelper('custom', function (context, options) {
    return 'custom helpers!'
  })
}

// custom-template.hbs
Now you can use {{custom}}

FAQ

What’s a changelog?

See keepachangelog.com.

What does this do?

The command parses your git commit history and generates a changelog based on tagged versions, merged pull requests and closed issues. See a simple example in this very repo.

Why do I need it?

Because keeping a changelog can be tedious and difficult to get right. If you don’t have the patience for a hand-crafted, bespoke changelog then this makes keeping one rather easy. It also can be automated if you’re feeling extra lazy.

changelog

Changelog

All notable changes to this project will be documented in this file. Dates are displayed in UTC.

Generated by auto-changelog.

v2.5.0

  • Fix: Throws error if tag does not contains "version" property #272
  • Add support for GitLab's new style routes #267
  • fix: gitlab subgroups #232
  • Add Template for handling commits with Conventional Commits format #217
  • upgrade parse-github-url v1.0.3 #289
  • tests: fix parseReleases #265
  • feat: combine multiple commit-lists to one if heading is undefined #236
  • Add a Plugin system #237
  • add support for including commit pattern #258
  • Revert GitLab's new style routes b087f51
  • Remove email from package.json 0991f17

v2.4.0

3 February 2022

  • Logical handling of --starting-version #227
  • Trim commit subject #225
  • feat(commits.js): added niceDate format of commits #206
  • Logical handling of --starting-version (#227) #221
  • Add ending-version option #209
  • Do not sort tags when sorting via --append-git-tag #197 #210
  • Bump packages 9d271fc
  • yarn upgrade c227823
  • --ending-version fixes dbd36d5

v2.3.0

23 May 2021

  • feat: add support for minor/preminor versions for custom templates #185
  • Feat: add sortCommits by subject and subject-desc #186
  • Remove --sort=-creatordate from git tag logic #196
  • Add --append-git-tag #190
  • Add --hide-empty-releases #189
  • Add --starting-date #181
  • Support absolute paths for --handlebars-setup #180
  • Fix unreleased version diff #174
  • Fix v prefix logic #33
  • Fix getSubject edge case #179 #184
  • Apply ignoreCommitPattern earlier in the parsing logic #195 #187
  • Add minor boolean to test data a80e311
  • Remove unused sortTags syntax 1b29530
  • Remove lodash.uniqby 26e7d9c

v2.2.1

18 September 2020

  • Remove requirement for --latest-version to be valid semver #178
  • Mild refactor 1fc916c

v2.2.0

3 July 2020

  • add --prepend option as altenative to prepend-token #172
  • Fix bug when no existing tags #170

v2.1.0

14 June 2020

  • Add --hide-credit option #166
  • Add --unreleased-only option #165
  • Fix --starting-version #164
  • Add ability to prepend to an existing changelog #156
  • Use tag date rather than first commit date #162
  • Add CONTRIBUTING.md #141
  • Add merge and fix support to commit-list helper #146

v2.0.0

10 April 2020

  • Refactor codebase #144
  • Breaking change: Remove the need for core-js and building with babel 2383380
  • Breaking change: Refactor git data fetching logic 09325ac
  • Improve progress output a2ba4ac

v1.16.4

2 April 2020

  • Pin semver to v6 #160
  • Add node 12 to travis builds ac77a53
  • Remove node 8 from travis builds e7d557d

v1.16.3

25 March 2020

v1.16.2

29 October 2019

  • fix parsing of --issue-url and -i options #138
  • Use noEscape option rather than triple brackets everywhere #131 #133

v1.16.1

4 September 2019

  • Encode < and > in commit messages #129
  • Update test data generation c2c9bd8
  • Refactor release parsing b1ab27e
  • Add HTML characters to test data b4eb7d7

v1.16.0

31 August 2019

  • Add --commit-url, --merge-url and --compare-url options #93
  • Bump packages 84a1bda
  • Update readme a04c0ff
  • Lint fixes 7d3c25a

v1.15.0

13 August 2019

  • Add --config option #127
  • Infer semver versions from numeric tags #126

v1.14.1

8 July 2019

  • Add regenerator-runtime dependency #125

v1.14.0

7 July 2019

  • Update babel/rimraf/nyc #122
  • HTTPS links to external sites #120
  • Add support for alternate date sorting #113
  • fix for handlebars-setup arg #110
  • Add --append-git-log option #118 #117
  • Update test data bb3a347
  • Add commit object to merge data 2a8de35
  • Fix commander argument syntax 01739fe

v1.13.0

16 April 2019

  • Support partial semver tag sorting #94
  • Update --package option to accept file path #106
  • Tidy up getOptions 0168216
  • Tidy up readJson util 36bfd9e
  • Space out error logs 2bc35ce

v1.12.1

11 April 2019

  • Change behaviour of ignoreCommitPattern to see tags on ignored commits #102
  • Bump packages b371147
  • Remove greenkeeper b0841c8

v1.12.0

18 March 2019

  • Add main entry to package.json #87
  • Update mocha to the latest version 🚀 #88
  • Add --merge-pattern option #86
  • yarn upgrade #91
  • Add --handlebars-setup option #96 #89 #90
  • Add --sort-commits option #95 #97

v1.11.0

14 January 2019

  • Add --stdout option #83
  • Fix sortReleases for non-semver tags #81
  • Add backtick characters to test data ab73c8a

v1.10.3

4 January 2019

  • Clarify includeBranch config array in readme #75
  • Remove package-lock.json from repo 512205b
  • Sort and slice commits for latest release 7d7f377
  • Fix breaking commit sorting 73c05a1

v1.10.2

18 November 2018

  • Upgrade all packages #59
  • Remove package-lock.json 791a261

v1.10.1

13 November 2018

  • Use readline for log util #73 #74

v1.10.0

10 November 2018

v1.9.0

8 November 2018

  • Add support for azure devops and visualstudio.com #72
  • Bump packages #56 #60 #61
  • Add --tag-pattern option #70
  • Add support for .auto-changelog config #66
  • Add --release-summary option #69
  • Add tests for .auto-changelog feature 17b0926
  • Add tests for sortReleases 9d80b9d
  • Fix quote style 5c18eda

v1.8.1

8 October 2018

  • Fix Bitbucket compare links. #65
  • Update markdownlint-cli to the latest version 🚀 #54
  • Update markdownlint-cli to the latest version 🚀 #51
  • Add author to fixes and merges #58
  • Remove unsupported node versions from travis builds df63917
  • Add timeout to URL fetching test d635a06
  • Add node 6.0 to travis builds 088077e

v1.8.0

23 July 2018

  • Add support for external templates #49 #50
  • Bump nyc #46
  • Add README.md to lint checks 5aab29f
  • Tweak readme headings 9f08899
  • Remove git from engines bac0248

v1.7.2

28 June 2018

  • Fix releases sorting when unreleased enabled #45
  • Fix unreleased section sorting #48
  • Add markdown linting #47
  • Use async fs utils instead of fs-extra #42
  • Update git log format to support earlier git versions #43
  • Fix changelog spacing 5e8ffe5
  • Use %B for supported git versions 1b9c3d7
  • Enable partial line coverage with codecov e0d24de

v1.7.1

31 May 2018

  • Use async fs utils instead of fs-extra #42
  • Update git log format to support earlier git versions #43

v1.7.0

23 May 2018

  • Add replaceText package option 77d73ee

v1.6.0

17 May 2018

  • Add --breaking-pattern option #41
  • Add --include-branch option #38
  • Fix duplicate test data commit hashes 7f448ce

v1.5.0

16 May 2018

  • Feat: match template helper #40
  • Add commit-list template helper #36 #39
  • Use UTC dates by default #37
  • Move helper tests to separate files 71388c2
  • Remove unused imports from template tests 5ca7c61

v1.4.6

15 March 2018

  • Added support for old git versions #35

v1.4.5

27 February 2018

  • Correctly prefix package version #33

v1.4.4

22 February 2018

  • Do not show date for unreleased section #31
  • Fix unreleased compare URL 24fbc63

v1.4.3

21 February 2018

  • Add tag prefix to compare URLs #30

v1.4.2

20 February 2018

  • Support for gitlab subgroups and self-hosted instances #28
  • Update standard to the latest version 🚀 #29

v1.4.1

30 January 2018

  • Support commits with no message #27

v1.4.0

18 January 2018

  • Update mocha to the latest version 🚀 #26
  • Add support for generating logs without a git remote #23
  • Update niceDate tests to avoid timezone issues #24 #25
  • Add --tag-prefix option #22
  • Change use of "origin" to "remote" 7c9c175
  • Add --ignore-commit-pattern option 8cbe121
  • Add merge commit to test data 4462118

v1.3.0

21 December 2017

  • Update fs-extra to the latest version 🚀 #19
  • Add --starting-commit option #21
  • Add --issue-pattern option #18
  • Add --latest-version option #17
  • Override package options with command line options 20e3962
  • Update tests 2a74da4

v1.2.2

5 December 2017

  • Fix error when using --unreleased flag #16

v1.2.1

4 December 2017

  • Filter out merge commits #14
  • Add commit to test data to trigger sorting 9aa7ed4
  • Add tests 02613a3
  • Add commit with matching PR message to test data e9a43b2

v1.2.0

1 December 2017

  • Add issue-url option to override issue URLs #13
  • Add major release to test data e14f753
  • Update readme aaa69d0
  • Slightly larger heading for major releases d618f01

v1.1.0

9 November 2017

  • Support modifying commit limit with --commit-limit #12
  • Move test origins to separate file f8b98b5
  • Add origin tests f50dced
  • Add run tests a6ae95e

v1.0.3

7 November 2017

v1.0.2

31 October 2017

  • Tweak package read logic 5ca75a2
  • Fall back to https origin protocol 74e29b4

v1.0.1

27 October 2017

  • Filter out commits with the same message as an existing merge 2a420f7
  • Update readme 54fc665

v1.0.0

27 October 2017

  • Update dependencies to enable Greenkeeper 🌴 #10
  • Refactor codebase dab29fb
  • Add greenkeeper-lockfile support 126c6fb
  • Tweak readme badges bf73f55

v0.3.6

23 October 2017

  • Use origin hostname instead of host #9
  • Correct bitbucket compare URLs 9d34452

v0.3.5

6 October 2017

  • Add babel-polyfill #8

v0.3.4

5 October 2017

  • Add code coverage 786af11
  • Use async/await instead of promises dff4653
  • Remove need for array.find polyfill 78a1cb8

v0.3.3

24 September 2017

v0.3.2

14 September 2017

  • Prevent duplicate commits being listed #3

v0.3.1

9 September 2016

  • Improve origin URL parsing #2 #5
  • Remove semicolons 2ff61e2
  • More robust log separators adc1dcc
  • Improve error handling 96b7666

v0.3.0

11 January 2016

  • Add semicolons after class properties 07b2de5
  • Remove unique issue filter 11acb7e
  • Add support for minimumChangeCount in templates 612d80b

v0.2.2

2 January 2016

  • Add a commit-only release to test data 99927a9
  • Update templating logic 12c0624
  • More sensible formatDate db92947

v0.2.1

2 January 2016

  • Replace toLocaleString usage with months array 0008264

v0.2.0

2 January 2016

v0.1.1

31 December 2015

  • Explicitly render links for PRs and issues 0a384cd
  • Fix --package bug 7f12f81

v0.1.0

31 December 2015

  • Add option for specifying output file #1
  • Add support for --package 772fbb9
  • Update badges d17791f
  • Remove todo list from readme 4446226

v0.0.1

31 December 2015