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

Correct way to configure a release channel (not based on branch)

Open bric3 opened this issue 3 years ago • 0 comments
trafficstars

I'd like to publish released versions of a software per channel. Where the channel is appended to the version number, this is important as the distribution mechanism rely on the suffix to route the release.

I recognize this is similar to release marker like beta, rc, but not quite the same as the marker here will serve as routing in the distribution channel on which I don't have control.

E.g here's what the release would look like on a channel eap,

  • v0.1.0-eap
  • v0.1.1-eap
  • v0.1.2-eap
  • v0.2.0-eap

But at the same time I'd like to publish some of these version in a different channel.

  • v0.1.0-beta
  • v0.2.0-beta

The channel can be configured via a property so I'd like to make releases in a row on x channels

$ ./gradlew release -Pchannel=eap
$ ./gradlew release -Pchannel=beta

That would produce multiple tag on a single commit.

$ git log --no-walk --tags
commit 60e939a66ab445729ef94808b912ac6670d320a1 (HEAD -> master, tag: v0.2.3-eap, tag: v0.2.3-beta, origin/master, origin/HEAD)
...

Unfortunately the second release command bails out as the current commit is already tagged, this can be overridden by Prelease.forceSnapshot but then it increments the version. I think setting a no-op versionIncrementer could help, but only for the second release command, and I'm unsure about that.

Here's what I came up until now, and wondered if someone could second guess or suggest better alternatives.

val channel = properties("pluginVersionChannel")

scmVersion {
//    nextVersion(closureOf<pl.allegro.tech.build.axion.release.domain.NextVersionConfig> {
//        suffix = channel
//        separator = "-"
//    })

    tag(closureOf<pl.allegro.tech.build.axion.release.domain.TagNameSerializationConfig> {
        serialize = KotlinClosure2<pl.allegro.tech.build.axion.release.domain.properties.TagProperties, String, String>(
            function = { _, version ->
                "v${version}-${channel}"
            },
            owner = this,
            thisObject = this
        )
    })

    snapshotCreator = KotlinClosure2<String, pl.allegro.tech.build.axion.release.domain.scm.ScmPosition, String>(
        function = { _, position ->
            "-${position.shortRevision}"
        },
        owner = this,
        thisObject = this
    )

    checks(closureOf<pl.allegro.tech.build.axion.release.domain.ChecksConfig> { isUncommittedChanges = false })
}

version = scmVersion.version

There are other approach to having multiple command, I think the less error error prone would be to pass channels as a list. Something like :

$ ./gradlew release -Pchannel=beta,eap

And this command will write the two tags on the current commit.

bric3 avatar Dec 03 '21 13:12 bric3