@@ -19,51 +19,54 @@ GitVersion has three distinct steps for calculating versions in v3.
19
19
1 . If the current commit is tagged, the tag is used and build metadata
20
20
(excluding commit count) is added. The other two steps will not execute.
21
21
2 . A set of strategies are evaluated to decide on the base version and some
22
- metadata about that version. These strategies include HighestReachableTag,
23
- NextVersionInConfig, MergedBranchWithVersion, VersionInBranchName etc.
22
+ metadata about that version. See [ Version Strategies] ( #version-strategies )
24
23
3 . The highest base version is selected, using that base version as the new
25
24
version is calculated.
26
25
27
26
Visually it looks something like this:
28
27
29
- ![ Version Calculation] ( https://www.plantuml.com/plantuml/png/fLCxJyCm4DxzAsuib4P914i69De1CS38Vd6kYIN7ZcodK8aVp-KX6Y2fKCbY9NV-7lVb2WoOeoVOMRDNfH0lz1vUoNbbpGwrR3K6ws1p3rlk-bN8u972f2AC3GHEbLN8m1D1Jjg-mPuXAZvx9kL1ZW1KY5dOZczMI0Pf54VnHtf7jpaAWJg0sW-uXw4PK3Eb1sMaevfCW6i1 \_ 0m6po1l7HfPJUxvu5XYUOHLWq5MLptCudmMK9--u5glJ0dIEaVo1Dw3JgVM6Km4cM9mzyrQXHuQHnj7chhl0JcnIrHjno1wiWtgfi8eWVK \_ 7OQAmBHrJWvORFVM2PmrE7AcWZGh-Lj0FvptVvLiUPnCdG_XhNhOov9wQ1fzv7nw5S5EwSvw6CDQNfnMwUAP0XQyQpj70nkx3Nn3p5NFY9IshbNWepKi8ublWFiSPkC0ee8El75Dv5aOxqZQBScbWpWn0Pe2wb6aM1p4Eea \_ 0G00 )
28
+ ![ Version Calculation] ( https://www.plantuml.com/plantuml/png/fLCxJyCm4DxzAsuib4P914i69De1CS38Vd6kYIN7ZcodK8aVp-KX6Y2fKCbY9NV-7lVb2WoOeoVOMRDNfH0lz1vUoNbbpGwrR3K6ws1p3rlk-bN8u972f2AC3GHEbLN8m1D1Jjg-mPuXAZvx9kL1ZW1KY5dOZczMI0Pf54VnHtf7jpaAWJg0sW-uXw4PK3Eb1sMaevfCW6i1_0m6po1l7HfPJUxvu5XYUOHLWq5MLptCudmMK9--u5glJ0dIEaVo1Dw3JgVM6Km4cM9mzyrQXHuQHnj7chhl0JcnIrHjno1wiWtgfi8eWVK_7OQAmBHrJWvORFVM2PmrE7AcWZGh-Lj0FvptVvLiUPnCdG_XhNhOov9wQ1fzv7nw5S5EwSvw6CDQNfnMwUAP0XQyQpj70nkx3Nn3p5NFY9IshbNWepKi8ublWFiSPkC0ee8El75Dv5aOxqZQBScbWpWn0Pe2wb6aM1p4Eea_0G00 )
30
29
31
- [ Edit Diagram] ( https://www.plantuml.com/plantuml/form?url=https://www.plantuml.com/plantuml/png/ fLCxJyCm4DxzAsuib4P914i69De1CS38Vd6kYIN7ZcodK8aVp-KX6Y2fKCbY9NV-7lVb2WoOeoVOMRDNfH0lz1vUoNbbpGwrR3K6ws1p3rlk-bN8u972f2AC3GHEbLN8m1D1Jjg-mPuXAZvx9kL1ZW1KY5dOZczMI0Pf54VnHtf7jpaAWJg0sW-uXw4PK3Eb1sMaevfCW6i1 \_ 0m6po1l7HfPJUxvu5XYUOHLWq5MLptCudmMK9--u5glJ0dIEaVo1Dw3JgVM6Km4cM9mzyrQXHuQHnj7chhl0JcnIrHjno1wiWtgfi8eWVK \_ 7OQAmBHrJWvORFVM2PmrE7AcWZGh-Lj0FvptVvLiUPnCdG_XhNhOov9wQ1fzv7nw5S5EwSvw6CDQNfnMwUAP0XQyQpj70nkx3Nn3p5NFY9IshbNWepKi8ublWFiSPkC0ee8El75Dv5aOxqZQBScbWpWn0Pe2wb6aM1p4Eea \_ 0G00 )
30
+ [ Edit Diagram] ( https://www.plantuml.com/plantuml/uml/ fLCxJyCm4DxzAsuib4P914i69De1CS38Vd6kYIN7ZcodK8aVp-KX6Y2fKCbY9NV-7lVb2WoOeoVOMRDNfH0lz1vUoNbbpGwrR3K6ws1p3rlk-bN8u972f2AC3GHEbLN8m1D1Jjg-mPuXAZvx9kL1ZW1KY5dOZczMI0Pf54VnHtf7jpaAWJg0sW-uXw4PK3Eb1sMaevfCW6i1_0m6po1l7HfPJUxvu5XYUOHLWq5MLptCudmMK9--u5glJ0dIEaVo1Dw3JgVM6Km4cM9mzyrQXHuQHnj7chhl0JcnIrHjno1wiWtgfi8eWVK_7OQAmBHrJWvORFVM2PmrE7AcWZGh-Lj0FvptVvLiUPnCdG_XhNhOov9wQ1fzv7nw5S5EwSvw6CDQNfnMwUAP0XQyQpj70nkx3Nn3p5NFY9IshbNWepKi8ublWFiSPkC0ee8El75Dv5aOxqZQBScbWpWn0Pe2wb6aM1p4Eea_0G00 )
32
31
33
32
** \* ** Some strategies allow the version to be incremented, others don't. More
34
33
info below.
35
34
** +** This version is out of context with the rest of the example. It is here
36
35
simply to show what happens if the check is true.
37
36
38
- ### Base Version Strategies
37
+ ### Version Strategies
39
38
40
39
Currently we have the following strategies:
41
40
42
- * ` HighestTagBaseVersionStrategy ` - Finds the highest reachable tag from the
43
- current branch
44
- * ` VersionInBranchBaseVersionStrategy ` - Extracts version information from the
45
- branch name (e.g., ` release/3.0.0 ` will find ` 3.0.0 ` )
46
- * ` ConfigNextVersionBaseVersionStrategy ` - Returns the version from the
47
- GitVersion.yaml file
48
- * ` MergeMessageBaseVersionStrategy ` - Finds version numbers from merge messages
49
- (e.g., ` Merge 'release/3.0.0' into 'main' ` will return ` 3.0.0 ` )
50
- * ` FallbackBaseVersionStrategy ` - Always returns 0.0.0 and will be used for
41
+ * ` Fallback ` - Always returns 0.0.0 and will be used for
51
42
calculating the next version which is dependent on the increment strategy of
52
- the effected branch (e.g. on main the next version is 0.0.1 or on develop it is 0.1.0)
43
+ the effected branch (e.g. on main the next version is 0.0.1 or on develop it is 0.1.0).
44
+ The fallback strategy only applies if no other selected strategy returns a base version.
45
+ * ` ConfiguredNextVersion ` - Returns the version from the GitVersion.yaml file
46
+ * ` MergeMessage ` - Finds version numbers from merge messages
47
+ (e.g., ` Merge 'release/3.0.0' into 'main' ` will return ` 3.0.0 ` )
48
+ * ` TaggedCommit ` - Extracts version information from all tags on the branch which are valid,
49
+ and not newer than the current commit.
50
+ * ` TrackReleaseBranches ` - Considers the base version extracted from release branches when
51
+ calculating the next version for branches configured with ` track-release-branches: true `
52
+ (part of default configuration for ` develop ` branch in ` GitFlow ` workflow)
53
+ * ` VersionInBranchName ` - Extracts version information from the
54
+ branch name (e.g., ` release/3.0.0 ` will find ` 3.0.0 ` )
55
+ * ` Mainline ` - Increments the version on every commit for branches configured with ` is-main-branch: true `
53
56
54
57
Each strategy needs to return an instance of ` BaseVersion ` which has the
55
58
following properties:
56
59
57
60
* ` Source ` - Description of the source (e.g., ` Merge message 'Merge 'release/3.0.0' into 'main' ` )
58
61
* ` ShouldIncrement ` - Some strategies should have the version incremented,
59
- others do not (e.g., ` ConfigNextVersionBaseVersionStrategy ` returns false,
60
- ` HighestTagBaseVersionStrategy ` returns true)
62
+ others do not (e.g., ` ConfiguredNextVersion ` returns false,
63
+ ` TaggedCommit ` returns true)
61
64
* ` SemanticVersion ` - SemVer of the base version strategy
62
65
* ` BaseVersionSource ` - SHA hash of the source. Commits will be counted from
63
- this hash. Can be null (e.g., ` ConfigNextVersionBaseVersionStrategy ` returns
66
+ this hash. Can be null (e.g., ` ConfiguredNextVersion ` returns
64
67
null).
65
68
* ` BranchNameOverride ` - When ` useBranchName ` or ` {BranchName} ` is used in the
66
69
tag configuration, this allows the branch name to be changed by a base version.
67
- ` VersionInBranchBaseVersionStrategy ` uses this to strip out anything before the
70
+ ` VersionInBranchName ` uses this to strip out anything before the
68
71
first ` - ` or ` /. ` so ` foo ` ends up being evaluated as ` foo ` . If in doubt, just
69
72
use null.
0 commit comments