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

Rc incrementors

Open levsa opened this issue 9 years ago • 7 comments
trafficstars

Created predefined incrementers:

  • createMajorRC: Create a prerelase with -RC1 for the next major version
  • createMinorRC: Create a prerelease with -RC2 for the next minor version
  • incrementPrereleaseOrMinor: Increment prerelease if already on prerelease, otherwise minor

Also created "createFinal" to release a final version from a prerelease, but couldn't make it work without using "release.forceSnapshot". There is an ignored test for it. It can be used as follows though:

task releaseFinal {
    finalizedBy release
    doFirst {
        project.ext["release.versionIncrementer"] = 'createFinal'
        project.ext["release.forceSnapshot"] = true
    }
}

levsa avatar May 26 '16 13:05 levsa

Coverage Status

Coverage increased (+1.05%) to 61.657% when pulling 281577a31099cd45f6018f5220c1685ad1ddc29b on levsa:rc-incrementors into 6ad80bb5c61d00e65864b2e8398fe6abb88fe1db on allegro:master.

coveralls avatar May 26 '16 13:05 coveralls

Similar approach could be also useful with beta versions. I wonder is it worth to extend it (probably in an another PR) to support parameterized incrementers (with prefix as a parameter like beta1, beta.1, rc-1, etc.) or it would be enough to just have two additional tasks CREATE_MAJOR_BETA and CREATE_MINOR_BETA?

szpak avatar May 26 '16 14:05 szpak

I wonder if we could use some Gradle magic here and extract the suffix from task name? What i mean is dynamic tasks like create[Minor/Major][Suffix].

adamdubiel avatar May 31 '16 11:05 adamdubiel

The suffix could be configured in the scmVersion configuration like other configuration, e.g. in the versionIncrementer section perhaps?

Alternatively, a project property, "release.releaseCandidateSuffix" could be used. Then it can be set from the task as you said. Task rules can be written like so:

tasks.addRule("Pattern: create<Major|Minor|Final><Suffix> \t- create a release candidate") { String taskName ->
    if (taskName.startsWith("create")) {
        logger.info "Adding $taskName"
        def p = /create(Major|Minor|Final)(.*)/
        def majorMinorFinal = taskName.replaceAll(p) { all, mm, s -> mm }
        def suffix = taskName.replaceAll(p) { all, mm, s -> s }
        task(taskName) {
            group = 'Creating release candidates'
            description = "Creates a ${majorMinorFinal} with suffix ${suffix}"
            doFirst {
                logger.lifecycle "Create ${majorMinorFinal} with suffix: ${suffix}"
                project.ext["release.releaseCandidateSuffix"] = suffix
                if (majorMinorFinal == 'Final') {
                    project.ext["release.versionIncrementer"] = 'createFinal'
                    project.ext["release.forceSnapshot"] = true
                } else {
                    project.ext["release.versionIncrementer"] = "create${majorMinorFinal}RC"
                }
            }
        }
    }
}

But I think it was much short to write the separate tasks createMajorRC, createMinorRC and createFinal.

levsa avatar Jun 01 '16 10:06 levsa

Could you give me a day or two to try other implementation? If i fail to find time/implement we will go with this pr.

adamdubiel avatar Jun 01 '16 11:06 adamdubiel

Of course, no hurries!

levsa avatar Jun 01 '16 11:06 levsa

I was just about to request this feature, when a noticed this PR. Great work :) Please, remember to update the docs when you decide how the tasks should look like.

jakubkrolewski avatar Aug 18 '16 14:08 jakubkrolewski