Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange master semantic versioning #39

Open
jeusdi opened this issue Jan 24, 2017 · 5 comments
Open

Strange master semantic versioning #39

jeusdi opened this issue Jan 24, 2017 · 5 comments
Labels

Comments

@jeusdi
Copy link

jeusdi commented Jan 24, 2017

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?

@dcoraboeuf
Copy link
Contributor

dcoraboeuf commented Jan 24, 2017

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.

@jeusdi
Copy link
Author

jeusdi commented Jan 27, 2017

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
Copy link
Author

jeusdi commented Aug 16, 2017

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?

@dcoraboeuf
Copy link
Contributor

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.

@jeusdi
Copy link
Author

jeusdi commented Aug 22, 2017

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants