UNPKG

6.16 kBMarkdownView Raw
1# Conventional Changelog plugin for release-it
2
3This plugin will provide the recommended bump to release-it, and update the changelog file (e.g. `CHANGELOG.md`).
4
5```
6npm install --save-dev @release-it/conventional-changelog
7```
8
9## Configuration
10
11In the [release-it](https://github.com/release-it/release-it) config, for example:
12
13```json
14"plugins": {
15 "@release-it/conventional-changelog": {
16 "preset": {
17 "name": "angular"
18 },
19 "infile": "CHANGELOG.md"
20 }
21}
22```
23
24Options are passed verbatim to
25[conventional-recommended-bump](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-recommended-bump#readme)
26and
27[conventional-changelog-core](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-core#api).
28
29### `preset`
30
31Use one of:
32
33- `angular`
34- `atom`
35- `codemirror`
36- `conventionalcommits`
37- `ember`
38- `eslint`
39- `express`
40- `jquery`
41- `jscs`
42- `jshint`
43
44Use an object with `name` and `types` to use a custom preset:
45
46```json
47"plugins": {
48 "@release-it/conventional-changelog": {
49 "infile": "CHANGELOG.md",
50 "preset": {
51 "name": "conventionalcommits",
52 "types": [
53 {
54 "type": "feat",
55 "section": "Features"
56 },
57 {
58 "type": "fix",
59 "section": "Bug Fixes"
60 },
61 {}
62 ]
63 }
64 }
65}
66```
67
68See the
69[Conventional Changelog Configuration Spec (v2.1.0)](https://github.com/conventional-changelog/conventional-changelog-config-spec/blob/master/versions/2.1.0/README.md)
70for the configuration object to pass as `preset`.
71
72### `infile`
73
74Default value: `undefined`
75
76- Set a filename as `infile` to write the changelog to. If this file does not exist yet, it's created with the full
77 history.
78- When `infile` is not set, the changelog generated by this plugin will still be used as release notes for e.g.
79 [GitHub Releases](https://github.com/release-it/release-it/blob/master/docs/github-releases.md).
80- Set `infile: false` to disable the changelog writing (and only use the recommended bump for the next version).
81
82### `header`
83
84Set the main header for the changelog document:
85
86```json
87{
88 "plugins": {
89 "@release-it/conventional-changelog": {
90 "infile": "CHANGELOG.md",
91 "header": "# Changelog",
92 "preset": {
93 "name": "conventionalcommits"
94 }
95 }
96 }
97}
98```
99
100### `ignoreRecommendedBump`
101
102Default value: `false`
103
104Use `true` to ignore the recommended bump, and use the version provided by release-it (command line argument or prompt).
105
106(Note that the changelog preview shows the recommended bump, as the desired version isn't known yet. The `infile` will
107have the correct version.)
108
109### `strictSemVer`
110
111Default value: `false`
112
113Use `true` to strictly follow semver, also in consecutive pre-releases. This means that from a pre-release, a
114recommended bump will result in a next pre-release for the next version.
115
116For example, from `1.0.0-alpha.0` a recommended bump of `minor` will result in a `preminor` bump to `1.1.0-alpha.0`
117(whereas the default behavior without this flag results in a `prerelease` bump to `1.0.0-alpha.1`).
118
119### `context`
120
121Default value: `undefined`
122
123This option will be passed as the second argument (`context`) to
124[conventional-changelog-core](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-core#context),
125for example:
126
127```json
128"plugins": {
129 "@release-it/conventional-changelog": {
130 "context": {
131 "linkCompare": false
132 }
133 }
134}
135```
136
137### `gitRawCommitsOpts`
138
139Default value: `undefined`
140
141Options for
142[`git-raw-commits`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/git-raw-commits#api).
143For example, you can use the following option to include merge commits into changelog:
144
145```json
146{
147 "plugins": {
148 "@release-it/conventional-changelog": {
149 "gitRawCommitsOpts": {
150 "merges": null
151 }
152 }
153 }
154}
155```
156
157### `parserOpts`
158
159Default value: `undefined`
160
161Options for
162[`conventional-commits-parser`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#api).
163For example, you can use the following option to set the merge pattern during parsing the commit message:
164
165```json
166{
167 "plugins": {
168 "@release-it/conventional-changelog": {
169 "parserOpts": {
170 "mergePattern": "^Merge pull request #(\\d+) from (.*)$"
171 }
172 }
173 }
174}
175```
176
177### `writerOpts`
178
179Default value: `undefined`
180
181Options for
182[`conventional-changelog-writer`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer#api).
183For example, you can use the following option to group the commits by 'scope' instead of 'type' by default.
184
185```json
186{
187 "plugins": {
188 "@release-it/conventional-changelog": {
189 "writerOpts": {
190 "groupBy": "scope"
191 }
192 }
193 }
194}
195```
196
197If you want to customize the templates used to write the changelog, you can do it like in a `.release-it.js` file like
198so:
199
200```js
201const fs = require('fs');
202
203const commitTemplate = fs.readFileSync('commit.hbs').toString();
204
205module.exports = {
206 plugins: {
207 '@release-it/conventional-changelog': {
208 writerOpts: {
209 commitPartial: commitTemplate
210 }
211 }
212 }
213};
214```
215
216## Command-line
217
218Options for this plugin can be set from the command line. Some examples:
219
220```
221release-it --plugins.@release-it/conventional-changelog.infile=history.md
222release-it --no-plugins.@release-it/conventional-changelog.infile
223```
224
225- Keys are separated by dots.
226- Values can be negated by prefixing the key with `no-`.
227- Arguments may need to be single-quoted (`'`) such as `--'deep.key=value'` or `'--deep.key=value'`
228
229Depending on your shell or OS this may differ.
230
231## GitHub Actions
232
233When using this plugin in a GitHub Action, make sure to set
234[`fetch-depth: 0`](https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches) so the history is
235available to determine the correct recommended bump and changelog.
236
237Also see https://github.com/release-it/release-it/blob/master/docs/ci.md#github-actions