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
Display the source diff
Display the rich diff
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).
@@ -659,7 +659,95 @@ version_scheme = "semver"
659
659
660
660
## Custom bump
661
661
662
-
Read the [customizing section](../customization.md).
662
+
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:
663
+
664
+
### Bump Pattern
665
+
666
+
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:
680
+
681
+
-`"MAJOR"`
682
+
-`"MINOR"`
683
+
-`"PATCH"`
684
+
685
+
Example for conventional commits:
686
+
```python
687
+
{
688
+
# Breaking changes (either by type or bang)
689
+
"breaking": "MAJOR", # When type is "BREAKING CHANGE"
690
+
"bang": "MAJOR", # When commit ends with ! (e.g., feat!: new feature)
691
+
# New features
692
+
"minor": "MINOR",
693
+
# Bug fixes and improvements
694
+
"patch": "PATCH",
695
+
}
696
+
```
697
+
698
+
Or using regex patterns:
699
+
```python
700
+
{
701
+
(r"^.+!$", "MAJOR"),
702
+
(r"^BREAKING[\-\ ]CHANGE", "MAJOR"),
703
+
(r"^feat", "MINOR"),
704
+
(r"^fix", "PATCH"),
705
+
(r"^refactor", "PATCH"),
706
+
(r"^perf", "PATCH"),
707
+
}
708
+
```
709
+
710
+
### Major Version Zero Map
711
+
712
+
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.
713
+
714
+
Example for conventional commits during initial development:
715
+
```python
716
+
{
717
+
# Breaking changes (either by type or bang)
718
+
"breaking": "MINOR", # When type is "BREAKING CHANGE"
719
+
"bang": "MINOR", # When commit ends with ! (e.g., feat!: new feature)
720
+
# New features
721
+
"minor": "MINOR",
722
+
# Bug fixes and improvements
723
+
"patch": "PATCH",
724
+
}
725
+
```
726
+
727
+
Or with regex patterns:
728
+
```python
729
+
{
730
+
(r"^.+!$", "MINOR"),
731
+
(r"^BREAKING[\-\ ]CHANGE", "MINOR"),
732
+
(r"^feat", "MINOR"),
733
+
(r"^fix", "PATCH"),
734
+
(r"^refactor", "PATCH"),
735
+
(r"^perf", "PATCH"),
736
+
}
737
+
```
738
+
739
+
This configuration will handle commit messages like:
740
+
741
+
-`BREAKING CHANGE: remove deprecated API` → MAJOR (or MINOR in major version zero)
742
+
-`feat!: add new API` → MAJOR (or MINOR in major version zero)
743
+
-`feat: add new feature` → MINOR
744
+
-`fix: fix bug` → PATCH
745
+
-`perf: improve performance` → PATCH
746
+
-`refactor: restructure code` → PATCH
747
+
748
+
For more details on implementing custom bump rules, see the [customization guide](../customization.md).
749
+
750
+
<!-- TODO: maybe sync the content with the customization guide? -->
0 commit comments