axion-release-plugin
axion-release-plugin copied to clipboard
CurrentVersion is returning old version
The plugin was working just fine until this release. Now it returning the wrong version. Here is the output of git tag:
1.0.0
1.1.0
1.1.0-SNAPSHOT
1.2.0
1.2.0-SNAPSHOT
1.3.0
1.3.0-SNAPSHOT
1.4.0
1.4.0-SNAPSHOT
1.5.0
1.5.0-SNAPSHOT
1.6.0
1.6.0-SNAPSHOT
1.7.0-SNAPSHOT
When executing gradle currentVersion I would expect it to return 1.7.0-SNAPSHOT. Instead it returns:
Project version: 1.6.0
This means when trying to do a release it says:
Working on released version 1.6.0, nothing to release
Relevant Gradle config:
plugins {
id("pl.allegro.tech.build.axion-release").version("1.18.13")
}
scmVersion {
useHighestVersion()
tag {
initialVersion({ _, _ -> "1.0.0" })
prefix = ""
}
nextVersion {
suffix.set("SNAPSHOT")
separator.set("-")
}
versionIncrementer("incrementMinor")
repository {
pushTagsOnly.set(true)
remote.set(System.getenv("CI_SERVER_URL") + "/" + System.getenv("CI_PROJECT_NAMESPACE") + "/" + System.getenv("CI_PROJECT_NAME") + ".git")
}
}
How can I go about troubleshooting this?
To add some more information:
If I remove 1.6.0, it correctly says 1.6.0-SNAPSHOT and creates a 1.6.0 release. If I remove everything but the following:
1.6.0
1.6.0-SNAPSHOT
1.7.0-SNAPSHOT
It's broke again. If I add 1.7.0 and 1.8.0-SNAPSHOT, it claims the current version is 1.7.0. So I'm not sure why the behavior of the plugin changes once you get to 1.7.0-SNAPSHOT.
Hi, we will look into it. @radoslaw-panuszewski I think its do the tags filtering, we need to update the filter
@danshinton In the example you provided, do you have any commits after 1.6.0? Maybe your tags are on the same commit? It would be perfect if you would prepare a repository that shows the issue.
So when I created this ticket, if I create a repo and just called release -Prelease.disableChecks -Prelease.pushTagsOnly and markNextVersion over and over, it worked until 1.6.0 is released. I would use git fetch --prune --prune-tags to reset my local repo to test again.
This morning, it is working for some reason. So there must be some transient condition which is not triggering now.
@danshinton Do you configure the axion-release plugin in the root dir of your project? The plugin uses the current location as a root to check for git changes in the last commits after the tag. If no changes are found, it uses the last release version instead of a snapshot.
Hi,
I have a bit of the same problems with this config in a composite setup (mono-repo) in a sub-folder "app1" where the build.gradle includes this
plugins {
id("pl.allegro.tech.build.axion-release") version "1.18.16"
}
scmVersion {
versionCreator("versionWithBranch")
// ignoreUncommittedChanges.set(false)
repository {
println "Setting SCM Version directory to ${project.projectDir.parent}"
directory.set("${project.projectDir.parent}")
}
releaseOnlyOnReleaseBranches = true
releaseBranchNames = ['master', 'main']
}
and tags are
λ git tag
v0.1.0
v0.1.1
v0.1.2
v0.1.3
v0.1.4
v0.1.5
and I am on master but 1 commit ahead of last tag (v0.1.5)
λ git log
commit 8bb8dc2afff90da9185b7bb3846dfffab0fbd800 (HEAD -> master, origin/master, origin/HEAD)
Author: Lars Borup Jensen
Date: Thu Nov 28 10:17:19 2024 +0100
fup
commit 2699150194da937c34dc4719e609059f87778426 (tag: v0.1.5)
Author: Lars Borup Jensen
Date: Thu Nov 28 10:10:07 2024 +0100
ignorecommittedchanges
commit f819eb1381b1e35431525b3c0ab0b7535e9bdc71
Author: Lars Borup Jensen
Date: Thu Nov 28 09:50:37 2024 +0100
Updated README
I expected release plugin to return version "0.1.6-SNAPSHOT" but it returns
λ gradlew app1:currentVersion
> Task :app1:currentVersion
Project version: 0.1.5
UPDATE: It turns out that the VersionResolver uses path "app1" where latest commit is infact commit with tag 0.1.5. I expected it to use the directory set in repository in scmVersion.
Maybe I have a bit of an odd-case for this plugin, where I want to version from root in a composite mono-repository like setup, so I have
mono-repo
|- app1
|- app2
|- lib1
|- lib2
and I build apps independently but I want to release from root (mono-repo folder) because I want to use a single version across all applications, though they may have been build independently (or not at all for a specific version) to make sure I can do a checkout of a tag and see exactly which code was present, since libs (lib1 and lib2) are included. Anyhoo, I did a fork and added a config param to allow me to do this (see https://github.com/lborupj/axion-release-plugin/commit/5f5214f9748a7b704b60046a95ebd51c5a281730 )
plugins {
id("pl.allegro.tech.build.axion-release") version "1.18.16-root-path-versioning"
}
scmVersion {
versionCreator("versionWithBranch")
repository {
directory.set("${project.projectDir.parent}")
}
relativizeProjectRoot.set(false)
releaseOnlyOnReleaseBranches = true
releaseBranchNames = ['master', 'main']
}
version = scmVersion.version
allprojects {
project.version = rootProject.version
}
so now it will use "git log" from repository.directory rather than finding the relative path from that directory to do a "git log app1" (in this case).
Please not I haven't added/updated docs, dunno if anyone else is interested in this "feature"?