You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/commands/bump.md
+90-2Lines changed: 90 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -99,7 +99,7 @@ cz bump --changelog
99
99
### `--prerelease`
100
100
101
101
The bump is a pre-release bump, meaning that in addition to a possible version bump the new version receives a
102
-
pre-release segment compatible with the bump’s version scheme, where the segment consist of a _phase_ and a
102
+
pre-release segment compatible with the bump's version scheme, where the segment consist of a _phase_ and a
103
103
non-negative number. Supported options for `--prerelease` are the following phase names `alpha`, `beta`, or
104
104
`rc` (release candidate). For more details, refer to the
105
105
[Python Packaging User Guide](https://packaging.python.org/en/latest/specifications/version-specifiers/#pre-releases).
@@ -658,7 +658,95 @@ version_scheme = "semver"
658
658
659
659
## Custom bump
660
660
661
-
Read the [customizing section](../customization.md).
661
+
You can create custom bump rules to define how version numbers should be incremented based on your commit messages. This is done by configuring three main components:
662
+
663
+
### Bump Pattern
664
+
665
+
The `bump_pattern` is a regex pattern string used to match commit messages. It defines the structure of your commit messages and captures named groups for different types of changes. The captured groups will be used as keys in the bump map.
The `bump_map` defines how different commit types map to version increments. The keys in this dictionary must match the named capture groups from your pattern. The values are the version increment types:
679
+
680
+
-`"MAJOR"`
681
+
-`"MINOR"`
682
+
-`"PATCH"`
683
+
684
+
Example for conventional commits:
685
+
```python
686
+
{
687
+
# Breaking changes (either by type or bang)
688
+
"breaking": "MAJOR", # When type is "BREAKING CHANGE"
689
+
"bang": "MAJOR", # When commit ends with ! (e.g., feat!: new feature)
690
+
# New features
691
+
"minor": "MINOR",
692
+
# Bug fixes and improvements
693
+
"patch": "PATCH",
694
+
}
695
+
```
696
+
697
+
Or using regex patterns:
698
+
```python
699
+
{
700
+
(r"^.+!$", "MAJOR"),
701
+
(r"^BREAKING[\-\ ]CHANGE", "MAJOR"),
702
+
(r"^feat", "MINOR"),
703
+
(r"^fix", "PATCH"),
704
+
(r"^refactor", "PATCH"),
705
+
(r"^perf", "PATCH"),
706
+
}
707
+
```
708
+
709
+
### Major Version Zero Map
710
+
711
+
The `bump_map_major_version_zero` allows you to define different versioning behavior when your project is in initial development (major version is 0). This is useful for following semantic versioning principles where breaking changes in 0.x.x versions don't require a major version bump.
712
+
713
+
Example for conventional commits during initial development:
714
+
```python
715
+
{
716
+
# Breaking changes (either by type or bang)
717
+
"breaking": "MINOR", # When type is "BREAKING CHANGE"
718
+
"bang": "MINOR", # When commit ends with ! (e.g., feat!: new feature)
719
+
# New features
720
+
"minor": "MINOR",
721
+
# Bug fixes and improvements
722
+
"patch": "PATCH",
723
+
}
724
+
```
725
+
726
+
Or with regex patterns:
727
+
```python
728
+
{
729
+
(r"^.+!$", "MINOR"),
730
+
(r"^BREAKING[\-\ ]CHANGE", "MINOR"),
731
+
(r"^feat", "MINOR"),
732
+
(r"^fix", "PATCH"),
733
+
(r"^refactor", "PATCH"),
734
+
(r"^perf", "PATCH"),
735
+
}
736
+
```
737
+
738
+
This configuration will handle commit messages like:
739
+
740
+
-`BREAKING CHANGE: remove deprecated API` → MAJOR (or MINOR in major version zero)
741
+
-`feat!: add new API` → MAJOR (or MINOR in major version zero)
742
+
-`feat: add new feature` → MINOR
743
+
-`fix: fix bug` → PATCH
744
+
-`perf: improve performance` → PATCH
745
+
-`refactor: restructure code` → PATCH
746
+
747
+
For more details on implementing custom bump rules, see the [customization guide](../customization.md).
748
+
749
+
<!-- TODO: maybe sync the content with the customization guide? -->
0 commit comments