versioning icon indicating copy to clipboard operation
versioning copied to clipboard

Strange master semantic versioning

Open jeusdi opened this issue 8 years ago • 5 comments

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?

jeusdi avatar Jan 24 '17 13:01 jeusdi

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.

dcoraboeuf avatar Jan 24 '17 16:01 dcoraboeuf

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:

  1. If there's any prevouslt commit tagged the version should be 0.1.
  2. If it exists get it and use it as version

Could I get this behavior?

jeusdi avatar Jan 27 '17 08:01 jeusdi

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?

jeusdi avatar Aug 16 '17 11:08 jeusdi

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.

dcoraboeuf avatar Aug 17 '17 14:08 dcoraboeuf

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:

  1. Once I've just created the new branch (release/0.1) version should be: 0.1.0 where 0.1.0 is the last part of the current branch name and 0.1.0 is the number of commits after first commit in the branch.
  2. Imagine I've created 5 commits then version should be: 0.1.4 where 0.1.4 is the last part of the current branch name and 0.1.4 is the number of commits after first commit in the branch.

I hope I've explained so well...

jeusdi avatar Aug 22 '17 10:08 jeusdi