vivin / gradle-semantic-build-versioning

Gradle plugin to generate version-numbers and tags using semantic versioning
MIT License
85 stars 32 forks source link

Promote after pre-release doesn't seem to work #90

Closed vinjana closed 6 years ago

vinjana commented 6 years ago

I am considering to use the plugin in one of our projects and am playing around with it to figure out how it works. Thereby I encountered the following issue:

Given the following (complete) git history:

6ce0191 (HEAD -> master) [promote]
3444194 [major]
e1f2e36 [minor]
91db0d1 [new-pre-release]

At 3444194 gradlew printVersion shows: 1.0.0-alpha.0-SNAPSHOT. That is a pre-release tag-name, as expected. However at 6ce0191 gradlew printVersion gives an error message:

$ ./gradlew printVersion
FAILURE: Build failed with an exception.
* What went wrong:
Creating a new pre-release while also promoting a pre-release is not supported

From the documentation I interpret that in the default configuration you can switch between pre-release state and release state by "[new-pre-release]" and "[promote]", respectively. Should the result then not just be 1.0.0 in this situation (or maybe 1.0.0-SNAPSHOT)? Or am I getting something wrong about the working of the plugin?

In this context it might be relevant that I did not get pre-release numbering. If I extend the repository by a "continue" branch like this

* 904cd37 (HEAD -> continue) nothing
* 32ab94d nothing
* dbb0192 nothing
| * 6ce0191 (master) [promote]
| * 3444194 [major]
| * e1f2e36 [minor]
|/  
* 91db0d1 [new-pre-release]

Then doing ./gradlew printVersion on 904cd37 shows "0.1.0-alpha.0-SNAPSHOT". What I'd (naïvely) expect of a plugin would be that e.g. "alpha.0" gets increased to "alpha.1" and so on with non-"[promote]" commits like here. Is this also the behaviour that is intended by the example in the readme?

Finally, it seems that the closure in preRelease { bump = ... } never gets executed. At least System.err.println or throws do not result in gradlew --debug output.

It all seems like that all commits since the 91db0d1 commit get interpreted as "[new-pre-release]" commits.

I'd be grateful for some support in this issue or clarification about the working of the plugin!

Here are my configuration files:

buildscript { repositories { maven { url "https://plugins.gradle.org/m2/" } } dependencies { // The configuration of this plugin is in semantic-build-versioning.gradle. classpath group: 'gradle.plugin.net.vivin', name: 'gradle-semantic-build-versioning', version: '4.0.0' } }

apply plugin: 'net.vivin.gradle-semantic-build-versioning' // MIT


* semantic-build-versioning.gradle:
```gradle
tagPattern = ~/^\d+\.\d+\.\d+(?:-\S+)?$/

preRelease {
    startingVersion = 'alpha.0'

    // The bumping scheme is alpha.0 -> alpha.1 -> ... -> alpha.n
    bump = {
        "alpha.${((it - ~/^alpha\./) as int) + 1}"
    }
}
vivin commented 6 years ago

Yes, this is expected behavior because from the perspective of the plugin, you're trying to create a new pre-release it and promote it (since the last tag).

The plugin works based on tags, so you're describing a series of version bumps from the last tag, that when resolved into a single "bump", don't really make sense.

If you aren't interested in creating actual pre-release artifacts or tags, then you shouldn't create a new pre-release. It looks like the net effect of what you're doing is to have a single [major] bump.

vinjana commented 6 years ago

Would you mind describing somewhere in the documentation how your plugin is supposed to work with e.g. gitflow or githubflow? Or maybe elaborate somewhat on the use-cases for which you intended the plugin?

In the current documentation the meaning of the individual tasks and properties seems to be well described but leaves me kind of puzzled about how things work together.

vivin commented 6 years ago

@vinjana Yes that is a major shortcoming. I'm planning on adding some examples and a FAQ. Unfortunately, I'm busy with full-time work and full-time school so I haven't had a chance to get to it. I will try to get to it soon.