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

Rc incrementors #142

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Rc incrementors #142

wants to merge 3 commits into from

Conversation

levsa
Copy link
Contributor

@levsa levsa commented May 26, 2016

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
    }
}

@coveralls
Copy link

Coverage Status

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

@szpak
Copy link
Contributor

szpak commented May 26, 2016

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?

@adamdubiel
Copy link
Collaborator

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].

@levsa
Copy link
Contributor Author

levsa commented Jun 1, 2016

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.

@adamdubiel
Copy link
Collaborator

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.

@levsa
Copy link
Contributor Author

levsa commented Jun 1, 2016

Of course, no hurries!

@jakubkrolewski
Copy link

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.

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

Successfully merging this pull request may close these issues.

5 participants