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

Keeping a reference to the last released version #347

Open
jmini opened this issue Jan 9, 2021 · 0 comments
Open

Keeping a reference to the last released version #347

jmini opened this issue Jan 9, 2021 · 0 comments

Comments

@jmini
Copy link

jmini commented Jan 9, 2021

In my gradle.properties I want to keep trace of the version (example 1.6.0-SNAPSHOT) and the last released version lastVersion (example 1.5.3).

This allows me to use the lastVersion in different places (docs, baseline definition).


I am wondering if the release plugin could help me. Ideally:

The first commit:
[PATCH] [Gradle Release Plugin] - pre tag commit: '1.6.0'.

Would update both values:

--- a/gradle.properties
+++ b/gradle.properties
@@ -1,4 +1,4 @@
-version=1.6.0-SNAPSHOT
-lastVersion=1.5.3
+version=1.6.0
+lastVersion=1.6.0

The second commit:
[Gradle Release Plugin] - new version commit: '1.6.1-SNAPSHOT'.

--- a/gradle.properties
+++ b/gradle.properties
@@ -1,4 +1,4 @@
-version=1.6.0
+version=1.6.1-SNAPSHOT
 lastVersion=1.6.0
 

The idea I had until now was to add a new task that ensure that version == lastVersion during a release:

release {
    buildTasks = ['doRelease']
}

task doRelease {
    dependsOn(
        'checkLastVersionValue',
        // other release tasks
    )
}

task checkLastVersionValue {
    doLast {
        if(version.endsWith('SNAPSHOT')) {
            throw new GradleException("version '$version' ends with SNAPSHOT, this is not a release build!")
        }
        if(lastVersion != version) {
            throw new GradleException("lastVersion '$lastVersion' does not match version '$version', fix it in the 'gradle.properties' file.")
        }
    }
}

This is not perfect, but I least I will not forget to fix the value prior to a release.

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

No branches or pull requests

1 participant