jmongard / Git.SemVersioning.Gradle

Gradle plugin for automatically versioning a project using semantic versioning and conventional commits with change log support based on git commit messages.
https://plugins.gradle.org/plugin/com.github.jmongard.git-semver-plugin
Apache License 2.0
38 stars 4 forks source link

How to get current release version? #11

Closed szhem closed 2 years ago

szhem commented 2 years ago

Hello,

I'm trying to implement the following: all the commits into main branch should lead to a release and should be published into a maven repository with the correct version in its name, e.g. mylib-1.0.0.jar

Currently releaseVersion task seems to just create a tag and then all the accesses to semver.version will return next version and not the current/release one, even if HEAD points to a release commit.

Using this plugin I'd like to achieve the following

# show next version
./gradlew printVersion
Version: 1.0.0-SNAPSHOT+002.sha.7391461

# create a release tag and release commit
./gradlew releaseVersion 

# build an artifact
./gradlew build

# show an artifact and expect it to have released version 1.0.0
ls -l target/libs
total 248
-rw-r--r--  1 user  staff  33510 Nov 20 17:54 mylib-1.0.1-SNAPSHOT.jar

Could you please help me to understand how to use this plugin to be able to create artifacts with the release version in their names or could you please add an option so that semver.version returns release version in case HEAD points to a release commit?

szhem commented 2 years ago

I've found the issue - uncommitted local files within the repository lead to SHAPSHOT versions. So everything works as expected. Thanks a lot for the great plugin.