Skip to content

Commit

Permalink
Support versioning new monorepo multi-tag modules in pre-release
Browse files Browse the repository at this point in the history
IF the monorepo project is in pre-release and new module is added,
AND the new module is versioned via own tag,
THEN the module version should also be postfixed with pre-release
identifier.
  • Loading branch information
serpro69 committed Apr 20, 2024
1 parent 12869fd commit fc195ef
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class SemverKtPlugin : Plugin<Settings> {
project.rootProject.path -> null
else -> config.monorepo.modules.firstOrNull { m -> m.path == project.path }
}
logger.debug("{} project module config: {}", project.name, moduleConfig?.jsonString())
logger.debug("{} project module config: {}", project.name, moduleConfig?.jsonString())

it.description = "Create a tag for the next version"
it.config.set(config)
Expand Down Expand Up @@ -226,13 +226,14 @@ class SemverKtPlugin : Plugin<Settings> {
// set initial version
val setInitial by lazy { nextVersion != null && latestVersion == null }
val next = if (nextVersion != null && (setSnapshot || setNext || setInitial)) {
// initial major for new module
val major =
if (isMonorepo && setInitial && !isRoot) Semver(project.rootProject.version.toString()).major else null
// initial major and (possible) rc for new module
val (major, rc) = if (isMonorepo && setInitial && !isRoot) {
Semver(project.rootProject.version.toString()).let { it.major to it.preRelease }
} else null to null
val nextVer = when (major) {
null -> nextVersion
0 -> config.version.initialVersion
else -> Semver(major = major, minor = 0, patch = 0)
0 -> config.version.initialVersion.copy(preRelease = rc)
else -> Semver(major = major, minor = 0, patch = 0).copy(preRelease = rc)
}
project.version = nextVer
logger.debug("{} project version: {}", project, project.version)
Expand Down

0 comments on commit fc195ef

Please sign in to comment.