nextPreRelease

fun Version.nextPreRelease(preRelease: String? = null): Version(source)

Increments the version by its PRE-RELEASE identifier or produces the next pre-release of a stable version. The preRelease parameter's value is used for setting the pre-release identity when the version is stable or has a different pre-release name. If the version is already pre-release and the first identifier matches with the preRelease parameter, a simple incrementation will apply.

Returns a new version while the original remains unchanged.

Samples

import io.github.z4kn4fein.semver.Inc
import io.github.z4kn4fein.semver.LooseVersionSerializer
import io.github.z4kn4fein.semver.Version
import io.github.z4kn4fein.semver.VersionSerializer
import io.github.z4kn4fein.semver.constraints.toConstraint
import io.github.z4kn4fein.semver.inc
import io.github.z4kn4fein.semver.nextMajor
import io.github.z4kn4fein.semver.nextMinor
import io.github.z4kn4fein.semver.nextPatch
import io.github.z4kn4fein.semver.nextPreRelease
import io.github.z4kn4fein.semver.satisfies
import io.github.z4kn4fein.semver.satisfiesAll
import io.github.z4kn4fein.semver.satisfiesAny
import io.github.z4kn4fein.semver.toVersion
import io.github.z4kn4fein.semver.toVersionOrNull
import io.github.z4kn4fein.semver.withoutSuffixes
import kotlinx.serialization.json.Json

fun main() { 
   //sampleStart 
   val version = "1.0.0-alpha.1".toVersion()
println(version.nextPreRelease())
println(version.nextPreRelease(preRelease = ""))
println(version.nextPreRelease(preRelease = "alpha"))
println(version.nextPreRelease(preRelease = "SNAPSHOT")) 
   //sampleEnd
}