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
This plugin adds a flexible approach to adding semantic versioning to your gradle project.
5
+
It supports multi-module gradle projects, running in CI, and multiple types of git strategies.
11
6
12
-
## Overview
13
7
14
-
A Gradle plugin with a flexible approach to generating semantic versions, typically for use within a Gradle project. It supports running under Github Actions.
It comes bundled with a single Version Calculator that implements a target branch calculator: the version of the current branch is based on the latest version of the branch it targets, eg `develop` is branched from `main`, thus the version of `develop` is based on the current version of `main`.
17
19
18
20
The Target Branch Version Calculator includes two Branch Matching strategies:
19
-
-Flow - broadly based on a [Git Flow workflow](https://nvie.com/posts/a-successful-git-branching-model/) without release branches, the following branches are supported:
21
+
-`Flow` - Broadly based on a [Git Flow workflow](https://nvie.com/posts/a-successful-git-branching-model/) without release branches, the following branches are supported:
20
22
21
23
| branch | pre release label | target branch | example |
The `Flow` strategy is automatically selected if a `develop` branch is present, otherwise the `Flat` strategy is selected.
37
+
38
+
By default, the `Flow` strategy is selected if a `develop` branch is present, otherwise the `Flat` strategy will be used.
36
39
37
40
## Version Calculation
38
41
39
42
The semver is calculated primarily based on:
40
-
* the version of the target branch
41
-
* the current branch
42
-
* the branchMatching strategy
43
+
- The version of the target branch
44
+
- The current branch
45
+
- The branchMatching strategy
43
46
44
47
## Branch Matching Strategy
45
48
46
49
A Strategy contains a list of `BranchMatchingConfiguration` instances which are applied in order until the first match is reached, it contains the following properties:
47
-
* branch name regex
48
-
* target branch
49
-
* version modifier: modifies the major, minor or patch components of the semver
50
-
* version qualifier: optionally qualifies the semver with a prerelease label and build metadata
50
+
- branch name regex
51
+
- target branch
52
+
- version modifier: modifies the major, minor or patch components of the semver
53
+
- version qualifier: optionally qualifies the semver with a prerelease label and build metadata
51
54
52
55
The `VersionModifier` can be set for every `BranchMatchingConfiguration` instance in the strategy with the plugin extension:
53
56
@@ -108,18 +111,19 @@ semver {
108
111
_**PLEASE NOTE:**_ the `semver` stanza should be declared **before** the `semver` extension functions are used.
109
112
110
113
## Plugin Extension Properties
111
-
*`version: String` returns the calculated version
112
-
*`versionTagName: String` returns the tag name for the current calculated version, ie `tagPrefix` + `version`
114
+
-`version: String` returns the calculated version
115
+
-`versionTagName: String` returns the tag name for the current calculated version, ie `tagPrefix` + `version`
113
116
114
117
## Plugin Tasks
115
-
*`cv` that will print out the current calculated version
116
-
*`generateVersionFile` will generate `build/semver/version.txt` containing the raw version and the tag version
117
-
*`createAndPushVersionTag` will create a tag from `semver.versionTagName` and push the tag to the remote repo, take care to use `:createAndPushVersionTag` in a multi module project otherwise it will attempt to create duplicates
118
+
-`cv` that will print out the current calculated version
119
+
-`generateVersionFile` will generate `build/semver/version.txt` containing the raw version and the tag version
120
+
-`createAndPushVersionTag` will create a tag from `semver.versionTagName` and push the tag to the remote repo, take care to use `:createAndPushVersionTag` in a multi module project otherwise it will attempt to create duplicates
118
121
119
-
## Using with CI/CD
122
+
## Using with CI
120
123
121
-
Make sure to check out all branches & tags, eg using GitHub Actions:
124
+
When using this plugin in CI check out all branches & tags to ensure an accurate version calculation.
122
125
126
+
GitHub Actions Example:
123
127
```yaml
124
128
- name: Checkout
125
129
uses: actions/checkout@v3
@@ -128,4 +132,4 @@ Make sure to check out all branches & tags, eg using GitHub Actions:
128
132
```
129
133
130
134
## Not Supported
131
-
* Discrete versions for subprojects, all subprojects are calculated with the same version
135
+
- Discrete versions for subprojects, all subprojects are calculated with the same version
0 commit comments