axion-release-plugin icon indicating copy to clipboard operation
axion-release-plugin copied to clipboard

currentVersion not working [1.10.3 regression]

Open cslee00 opened this issue 5 years ago • 3 comments

When upgrading past 1.10.2 'currentVersion' fails to determine the correct version from the tags, as shown below. Issue exists for 1.11.0 and 1.12.0 as well, introduced in 1.10.3.

1.10.2:

$ git tag
release/0.1.1-alpha
release/1.7.5
release/1.7.5-alpha
$ ./gradlew cV

> Configure project :

> Task :currentVersion
Property 'versionConfig' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.5/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.

Project version: 1.7.5

1.10.3: (changing plugin on same project - no other changes)

$ git tag
release/0.1.1-alpha
release/1.7.5
release/1.7.5-alpha
$ ./gradlew cV

> Configure project :

> Task :currentVersion
Property 'versionConfig' is not annotated with an input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.5/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.

Project version: 0.1.0-SNAPSHOT

Configuration:

project.version = scmVersion.version

project.scmVersion {
    localOnly = true
    tag {
        prefix = 'release'
        versionSeparator = '/'
    }
}

cslee00 avatar Jun 22 '20 10:06 cslee00

I started debugging, but...

Did really nothing else change in your project? Because the configuration that you posted is incorrect and should have never worked. You configure scmVersion after the version was read, meaning customizations are ignored when reading version. Proper configuration:

// configure first
project.scmVersion {
    localOnly = true
    tag {
        prefix = 'release'
        versionSeparator = '/'
    }
}

// then use
project.version = scmVersion.version

This issue was raised multiple times in the past and even has separate section in docs :)

adamdubiel avatar Jul 18 '20 14:07 adamdubiel

I'm seeing the same behavior. Here's my build.gradle (its in a multi module build):

apply plugin: 'pl.allegro.tech.build.axion-release'

String getVersion(version) {
    def currentRevision = "git rev-parse HEAD".execute().text
    def branch = "git branch -r --contains $currentRevision".execute().text
    def dVersion = (branch.contains("origin/master")) ? version : currentRevision.trim()
    return dVersion
}

project.scmVersion {
    tag { prefix = project.name.replaceAll('-', '_') }
    versionIncrementer 'incrementMinor'
    versionCreator { version, position -> getVersion(version) }
    hooks { post { context -> project.version = getVersion(context.currentVersion) } }
}

project.version = project.findProperty('deployVersion') ?: scmVersion.version
git tag --points-at HEAD
cluster_autoscaler_image-0.7.0
../gradlew --version

------------------------------------------------------------
Gradle 6.8.3
------------------------------------------------------------

Build time:   2021-02-22 16:13:28 UTC
Revision:     9e26b4a9ebb910eaa1b8da8ff8575e514bc61c78

Kotlin:       1.4.20
Groovy:       2.5.12
Ant:          Apache Ant(TM) version 1.10.9 compiled on September 27 2020
JVM:          11.0.9 (Oracle Corporation 11.0.9+0-adhoc..source)
OS:           Linux 5.4.122 amd64

In 1.10.+:

../gradlew cV
0.7.0

In 1.11.+ / 1.12.+:

../gradlew cV
0.8.0-SNAPSHOT

jsravn avatar Jun 29 '21 15:06 jsravn

Hmm - is it because the tagged commit is a merge commit?

jsravn avatar Jun 29 '21 15:06 jsravn