Strange master semantic versioning
gradle versionDisplay
:versionDisplay [version] scm = git [version] branch = master [version] branchType = master [version] branchId = master [version] commit = a4c3c40794e7ffd4fa7fa677dcb925714e0ce392 [version] full = master-a4c3c40 [version] base = [version] build = a4c3c40 [version] display = master-a4c3c40 [version] tag = v0.1 [version] dirty = false
As you can see I'm on master branch on a tagged commit 'v0.1'.
I'd like that the version semantic version is 0.1.0
Is there anyway to get it?
Hi,
Yes, you can just do something like:
version = versioning.info.tag
All the properties displayed above are available in your Gradle build, in the versioning.info object, as soon as the versioning plug-in has been applied.
However, your tag is here v0.1 not 0.1.0.
The versioning plug-in applies automatic versioning only on release/... branches (this is configurable - see the README) and relies on the previous or current tag information. Typically, by default, it cannot extract any information from v0.1 unless you code the logic yourself.
Thanks @dcoraboeuf
Currently, I'm pushing on dev branch. I'd like that the version pattern be like this on dev` branch:
{artifactName}-{version}-{unstable}{count(commit)}
Example: oauthz-0.1.0-unstable0023
Where:
"oauthz" -> artifactName
"0.1.0" -> version (extracted from a previous tag)
"unstable" -> constant in dev branch
"0023" -> Number of commits.
Nevertheless, on master branch I'd like to get this version:
{artifactName}-{version}
Example: oauthz-0.1.0
Where:
oauthz -> artifactName
0.1.2 -> version (extracted from a previous tag or release branch)
When I say that version should be extracted from a previous tag, I mean that:
- If there's any prevouslt commit tagged the
versionshould be0.1. - If it exists get it and use it as
version
Could I get this behavior?
Currently, I've stuck still on that. I don't quite to figure out how to work with this plugin:
Currently, I'm on master branch and it's tagged with 0.1.0. gradle versionDisplay shows me:
[version] scm = git
[version] branch = master
[version] branchType = master
[version] branchId = master
[version] commit = a4c3c40794e7ffd4fa7fa677dcb925714e0ce392
[version] full = master-a4c3c40
[version] base =
[version] build = a4c3c40
[version] display = master-a4c3c40
[version] tag = 0.1.0
[version] dirty = false
I'm not using release branches. I'm only using master, qa and dev.
I need to publish unstable artifacts from dev branch. So If master is tagged with 0.1.0, I would like to get a 0.1.{#commit}-unstable
Any ideas?
For very specific versioning schemes, you can use the releaseParser closure, as documented in the README:
versioning {
/**
* Computation of the release type and the base, by parsing the scm info.
* By default, we use "/" as a separator in branch name between the type and the base. If not
* present, the type is the branch and the base is empty.
* F.e. if you want use tag name instead of branch you may provide something like:
*/
releaseParser = { scmInfo, separator = '/' -> ->
List<String> part = scmInfo.tag.split('/') + ''
new net.nemerosa.versioning.ReleaseInfo(type: part[0], base: part[1])
}
}
You then take full control over your version computing. Other options are also available.
What are type and base for?
What I want to get is picking version part of branch/version branch name. For example: relase/0.1 -> 0.1 and adding the patch part of the semantic version according to the number of commits in the branch. For example:
- Once I've just created the new branch (
release/0.1) version should be:0.1.0where0.1.0is the last part of the current branch name and0.1.0is the number of commits after first commit in the branch. - Imagine I've created 5 commits then version should be:
0.1.4where0.1.4is the last part of the current branch name and0.1.4is the number of commits after first commit in the branch.
I hope I've explained so well...