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