Debian Codegraph @

docs/config/bump.md

raw
1 # Bump Options
2
3 <!-- When adding a new option, please keep the alphabetical order. -->
4
5 ## `annotated_tag`
6
7 When set to `true`, `cz bump` is equivalent to `cz bump --annotated-tag`.
8
9 ```toml title="pyproject.toml"
10 [tool.commitizen]
11 annotated_tag = true
12 ```
13
14 ## `bump_message`
15
16 Template used to specify the commit message generated when bumping.
17
18 Defaults to: `bump: version $current_version → $new_version`
19
20 | Variable | Description |
21 | ------------------ | ----------------------------------- |
22 | `$current_version` | the version existing before bumping |
23 | `$new_version` | version generated after bumping |
24
25 ```toml title="pyproject.toml"
26 [tool.commitizen]
27 bump_message = "release $current_version → $new_version [skip-ci]"
28 ```
29
30 ## `gpg_sign`
31
32 When set to `true`, `cz bump` is equivalent to `cz bump --gpg-sign`. See [`--gpg-sign`](../commands/bump.md#-gpg-sign).
33
34 ```toml title="pyproject.toml"
35 [tool.commitizen]
36 gpg_sign = true
37 ```
38
39 ## `ignored_tag_formats`
40
41 - Type: `list`
42 - Default: `[]`
43
44 Tags matching those formats will be totally ignored and won't raise a warning.
45 Each entry uses the syntax as [`tag_format`](#tag_format) with the addition of `*` that will match everything (non-greedy).
46
47 ## `major_version_zero`
48
49 When set to `true`, `cz bump` is equivalent to `cz bump --major-version-zero`. See [`--major-version-zero`](../commands/bump.md#-major-version-zero).
50
51 ```toml title="pyproject.toml"
52 [tool.commitizen]
53 major_version_zero = true
54 ```
55
56 ## `legacy_tag_formats`
57
58 - Type: `list`
59 - Default: `[]`
60
61 Legacy git tag formats, useful for old projects that changed tag format.
62 Tags matching those formats will be recognized as version tags and be included in the changelog.
63 Each entry uses the syntax as `tag_format`.
64
65 ## `pre_bump_hooks`
66
67 A list of optional commands that will run right *after* updating [`version_files`](#version_files) and *before* actual committing and tagging the release.
68
69 Useful when you need to generate documentation based on the new version. During
70 execution of the script, some environment variables are available:
71
72 | Variable | Description |
73 | ---------------------------- | ---------------------------------------------------------- |
74 | `CZ_PRE_IS_INITIAL` | `True` when this is the initial release, `False` otherwise |
75 | `CZ_PRE_CURRENT_VERSION` | Current version, before the bump |
76 | `CZ_PRE_CURRENT_TAG_VERSION` | Current version tag, before the bump |
77 | `CZ_PRE_NEW_VERSION` | New version, after the bump |
78 | `CZ_PRE_NEW_TAG_VERSION` | New version tag, after the bump |
79 | `CZ_PRE_MESSAGE` | Commit message of the bump |
80 | `CZ_PRE_INCREMENT` | Whether this is a `MAJOR`, `MINOR` or `PATCH` release |
81 | `CZ_PRE_CHANGELOG_FILE_NAME` | Path to the changelog file, if available |
82
83 ```toml title="pyproject.toml"
84 [tool.commitizen]
85 pre_bump_hooks = [
86 "scripts/generate_documentation.sh"
87 ]
88 ```
89
90 ## `post_bump_hooks`
91
92 A list of optional commands that will run right *after* committing and tagging the release.
93
94 Useful when you need to send notifications about a release, or further automate deploying the
95 release. During execution of the script, some environment variables are available:
96
97 | Variable | Description |
98 | ------------------------------ | ----------------------------------------------------------- |
99 | `CZ_POST_WAS_INITIAL` | `True` when this was the initial release, `False` otherwise |
100 | `CZ_POST_PREVIOUS_VERSION` | Previous version, before the bump |
101 | `CZ_POST_PREVIOUS_TAG_VERSION` | Previous version tag, before the bump |
102 | `CZ_POST_CURRENT_VERSION` | Current version, after the bump |
103 | `CZ_POST_CURRENT_TAG_VERSION` | Current version tag, after the bump |
104 | `CZ_POST_MESSAGE` | Commit message of the bump |
105 | `CZ_POST_INCREMENT` | Whether this was a `MAJOR`, `MINOR` or `PATCH` release |
106 | `CZ_POST_CHANGELOG_FILE_NAME` | Path to the changelog file, if available |
107
108 ```toml title="pyproject.toml"
109 [tool.commitizen]
110 post_bump_hooks = [
111 "scripts/slack_notification.sh"
112 ]
113 ```
114
115 ## `prerelease_offset`
116
117 Offset with which to start counting prereleases.
118
119 If not specified, defaults to `0`.
120
121 ```toml title="pyproject.toml"
122 [tool.commitizen]
123 prerelease_offset = 1
124 ```
125
126 !!! note
127 Under some circumstances, a prerelease cannot start with `0`-for example, in embedded projects where individual characters are encoded as bytes. You can specify an offset from which to start counting.
128
129 ## `tag_format`
130
131 See [`--tag-format`](../commands/bump.md#-tag-format).
132
133 ## `update_changelog_on_bump`
134
135 When set to `true`, `cz bump` is equivalent to `cz bump --changelog`.
136
137 ```toml title="pyproject.toml"
138 [tool.commitizen]
139 update_changelog_on_bump = true
140 ```
141
142 ## `version_files`
143
144 Identify the files or glob patterns which should be updated with the new version.
145
146 Commitizen will update its configuration file automatically when bumping,
147 regardless of whether the file is present or not in `version_files`.
148
149 You may specify the `version_files` in your configuration file.
150
151 ```toml title="pyproject.toml"
152 [tool.commitizen]
153 version_files = [
154 "src/__version__.py",
155 ]
156 ```
157
158 It is also possible to provide a pattern for each file, separated by a colon (e.g. `file:pattern`). See the below example for more details.
159
160 ```toml title="pyproject.toml"
161 [tool.commitizen]
162 version_files = [
163 "packages/*/pyproject.toml:version",
164 "setup.json:version",
165 ]
166 ```
167
168 !!! note "Example scenario"
169 We have a project with the following configuration file `pyproject.toml`:
170
171 ```toml title="pyproject.toml"
172 [tool.commitizen]
173 version_files = [
174 "src/__version__.py",
175 "packages/*/pyproject.toml:version",
176 "setup.json:version",
177 ]
178 ```
179
180 For the reference `"setup.json:version"`, it means that it will look for a file `setup.json` and will only change the lines that contain the substring `"version"`.
181
182 For example, if the content of `setup.json` is:
183
184 <!-- DEPENDENCY: repeated_version_number.json -->
185
186 ```json title="setup.json"
187 {
188 "name": "magictool",
189 "version": "1.2.3",
190 "dependencies": {
191 "lodash": "1.2.3"
192 }
193 }
194 ```
195
196 After running `cz bump 2.0.0`, its content will be updated to:
197
198 ```diff title="setup.json"
199 {
200 "name": "magictool",
201 - "version": "1.2.3",
202 + "version": "2.0.0",
203 "dependencies": {
204 "lodash": "1.2.3"
205 }
206 }
207 ```
208
209 !!! note
210 Files can be specified using relative (to the execution) paths, absolute paths, or glob patterns.
211
212 !!! note "Historical note"
213 This option was renamed from `files` to `version_files`.
214
215 ## `version_provider`
216
217 Mechanism by which Commitizen reads and writes version information in your project.
218
219 For a detailed explanation, check the [version provider](./version_provider.md) section.
220 Which includes, how to create your own version provider.
221
222 **Available options**
223
224 - `commitizen`: default version provider and stores the version in the active commitizen config (`pyproject.toml` or `.cz.toml`) under the key `version`
225 - `scm`: git tags provide the real version to commitizen (read only)
226 - `pep621`: (python) manages version in `pyproject.toml` under the `project.version` field, following [PEP 621](https://peps.python.org/pep-0621/) standards
227 - `poetry`: takes the version from poetry v1, use `pep621` with poetry v2 or later
228 - `uv`: same as `pep621` except that it also updates the `uv.lock`
229 - `cargo`: manages version in both `Cargo.toml` (`package.version`) and `Cargo.lock`
230 - `npm`: manages version in `package.json` and the lock
231 - `composer`: for PHP's Composer package manager
232
233 **Example**
234
235 ```toml
236 [tool.commitizen]
237 version_provider = "pep621"
238 ```
239
240 ## `version_scheme`
241
242 Format used for the version.
243
244 For a detail explanation, check [`--version-scheme`](../commands/bump.md#-version-scheme).
245
246 **Available options**
247
248 - `pep440`: [PEP 440](https://www.python.org/dev/peps/pep-0440/): recommended for Python projects, **default** (for legacy reasons)
249 - `semver2`: [Semantic Versioning](https://semver.org/): recommended for non-Python projects
250 - `semver`: [Semantic Versioning](https://semver.org/spec/v1.0.0.html): use if you are stuck with semver v1
251
252 **Example**
253
254
255 ```toml
256 [tool.commitizen]
257 version_scheme = "semver2"
258 ```