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": {
|
17 | "name": "angular"
|
18 | },
|
19 | "infile": "CHANGELOG.md"
|
20 | }
|
21 | }
|
22 | ```
|
23 |
|
24 | Options are passed verbatim to
|
25 | [conventional-recommended-bump](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-recommended-bump#readme)
|
26 | and
|
27 | [conventional-changelog-core](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-core#api).
|
28 |
|
29 | ### `preset`
|
30 |
|
31 | Use one of:
|
32 |
|
33 | - `angular`
|
34 | - `atom`
|
35 | - `codemirror`
|
36 | - `conventionalcommits`
|
37 | - `ember`
|
38 | - `eslint`
|
39 | - `express`
|
40 | - `jquery`
|
41 | - `jscs`
|
42 | - `jshint`
|
43 |
|
44 | Use 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 |
|
68 | See 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)
|
70 | for the configuration object to pass as `preset`.
|
71 |
|
72 | ### `infile`
|
73 |
|
74 | Default 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 |
|
84 | Set 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 |
|
102 | Default value: `false`
|
103 |
|
104 | Use `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
|
107 | have the correct version.)
|
108 |
|
109 | ### `strictSemVer`
|
110 |
|
111 | Default value: `false`
|
112 |
|
113 | Use `true` to strictly follow semver, also in consecutive pre-releases. This means that from a pre-release, a
|
114 | recommended bump will result in a next pre-release for the next version.
|
115 |
|
116 | For 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 |
|
121 | Default value: `undefined`
|
122 |
|
123 | This 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),
|
125 | for example:
|
126 |
|
127 | ```json
|
128 | "plugins": {
|
129 | "@release-it/conventional-changelog": {
|
130 | "context": {
|
131 | "linkCompare": false
|
132 | }
|
133 | }
|
134 | }
|
135 | ```
|
136 |
|
137 | ### `gitRawCommitsOpts`
|
138 |
|
139 | Default value: `undefined`
|
140 |
|
141 | Options for
|
142 | [`git-raw-commits`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/git-raw-commits#api).
|
143 | For 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 |
|
159 | Default value: `undefined`
|
160 |
|
161 | Options for
|
162 | [`conventional-commits-parser`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-commits-parser#api).
|
163 | For 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 |
|
179 | Default value: `undefined`
|
180 |
|
181 | Options for
|
182 | [`conventional-changelog-writer`](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-writer#api).
|
183 | For 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 |
|
197 | If you want to customize the templates used to write the changelog, you can do it like in a `.release-it.js` file like
|
198 | so:
|
199 |
|
200 | ```js
|
201 | const fs = require('fs');
|
202 |
|
203 | const commitTemplate = fs.readFileSync('commit.hbs').toString();
|
204 |
|
205 | module.exports = {
|
206 | plugins: {
|
207 | '@release-it/conventional-changelog': {
|
208 | writerOpts: {
|
209 | commitPartial: commitTemplate
|
210 | }
|
211 | }
|
212 | }
|
213 | };
|
214 | ```
|
215 |
|
216 | ## Command-line
|
217 |
|
218 | Options for this plugin can be set from the command line. Some examples:
|
219 |
|
220 | ```
|
221 | release-it --plugins.@release-it/conventional-changelog.infile=history.md
|
222 | release-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 |
|
229 | Depending on your shell or OS this may differ.
|
230 |
|
231 | ## GitHub Actions
|
232 |
|
233 | When 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
|
235 | available to determine the correct recommended bump and changelog.
|
236 |
|
237 | Also see https://github.com/release-it/release-it/blob/master/docs/ci.md#github-actions
|