Skip to content

Commit

Permalink
build: Drop the build part from the SemVer to get rid of the "+"
Browse files Browse the repository at this point in the history
Docker tags do not support "+" as part of their name [1], so turn e.g.
"3.0.1-SNAPSHOT+003.sha.cc0865e" into "3.0.1-003.sha.cc0865e" by using
the build part as the pre-release part. SemVer sorting rules [2] are still
so that 3.0.1-003.sha.cc0865e < 3.0.1.

[1]: moby/moby#16304
[2]: https://semver.org/#spec-item-11

Signed-off-by: Sebastian Schuberth <sschuberth@gmail.com>
  • Loading branch information
sschuberth committed Oct 5, 2023
1 parent cc0865e commit 898c9db
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion build.gradle.kts
Expand Up @@ -43,7 +43,12 @@ semver {

// Only override a default version (which usually is "unspecified"), but not a custom version.
if (version == Project.DEFAULT_VERSION) {
version = semver.semVersion.takeIf { it.isPreRelease } ?: semver.version
version = semver.semVersion.takeIf { it.isPreRelease }
// To get rid of a build part's "+" prefix because Docker tags do not support it, use only the original "build"
// part as the "pre-release" part.
?.toString()?.replace("${semver.defaultPreRelease}+", "")
// Fall back to a plain version without pre-release or build parts.
?: semver.version
}

logger.lifecycle("Building ORT version $version.")
Expand Down

0 comments on commit 898c9db

Please sign in to comment.