From be1559f5dea02ae2ac8b1c092aae1c1aae3a3ebd Mon Sep 17 00:00:00 2001 From: Julien Richard-Foy Date: Thu, 30 Nov 2023 15:44:06 +0100 Subject: [PATCH] Update after https://github.com/scalacenter/sbt-version-policy/pull/187 --- build.sbt | 7 +++-- project/Versioning.scala | 61 ---------------------------------------- project/plugins.sbt | 2 +- 3 files changed, 6 insertions(+), 64 deletions(-) delete mode 100644 project/Versioning.scala diff --git a/build.sbt b/build.sbt index 50ae9a0..5c2477b 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,4 @@ import ReleaseTransformations.* -import sbtversionpolicy.SbtVersionPolicyPlugin.aggregatedAssessedCompatibilityWithLatestRelease import sbtversionpolicy.withsbtrelease.ReleaseVersion ThisBuild / scalaVersion := "2.13.12" @@ -56,7 +55,11 @@ lazy val `etag-caching-root` = (project in file(".")) ).settings(baseSettings).settings( publish / skip := true, releaseCrossBuild := true, // true if you cross-build the project for multiple Scala versions - releaseVersion := ReleaseVersion.fromAggregatedAssessedCompatibility.value, + releaseVersion := { + ReleaseVersion.fromAggregatedAssessedCompatibilityWithLatestRelease( + qualifier = sys.env.getOrElse("RELEASE_VERSION_QUALIFIER", "") + ).value + }, releaseProcess := Seq[ReleaseStep]( checkSnapshotDependencies, inquireVersions, diff --git a/project/Versioning.scala b/project/Versioning.scala deleted file mode 100644 index 87513de..0000000 --- a/project/Versioning.scala +++ /dev/null @@ -1,61 +0,0 @@ -package sbtversionpolicy.withsbtrelease - -import sbtrelease.{ Version, versionFormatError } -import sbtversionpolicy.Compatibility -import sbtversionpolicy.SbtVersionPolicyPlugin.aggregatedAssessedCompatibilityWithLatestRelease - -import sbt._ -object ReleaseVersion { - - /** - * @return a [release version function](https://github.com/sbt/sbt-release?tab=readme-ov-file#custom-versioning) - * that bumps the patch, minor, or major version number depending on the provided - * compatibility level. - */ - def fromCompatibility(compatibility: Compatibility): String => String = { - val maybeBump = - compatibility match { - case Compatibility.None => Some(Version.Bump.Major) - case Compatibility.BinaryCompatible => Some(Version.Bump.Minor) - case Compatibility.BinaryAndSourceCompatible => None // No need to bump the patch version, because it has already been bumped when sbt-release set the next release version - } - { (currentVersion: String) => - val versionWithoutQualifier = - Version(currentVersion) - .getOrElse(versionFormatError(currentVersion)) - .withoutQualifier - (maybeBump match { - case Some(bump) => versionWithoutQualifier.bump(bump) - case None => versionWithoutQualifier - }).string - } - } - - /** - * Convenient task that returns a [release version function](https://github.com/sbt/sbt-release?tab=readme-ov-file#custom-versioning) - * based on the assessed compatibility level of the project (ie, the highest level of compatibility - * satisfied by all the sub-projects aggregated by this project). - * - * Use it in the root project of your `.sbt` build definition as follows: - * - * {{{ - * import sbtversionpolicy.withsbtrelease.ReleaseVersion - * - * val `my-project` = - * project - * .in(file(".")) - * .aggregate(mySubproject1, mySubproject2) - * .settings( - * releaseVersion := ReleaseVersion.fromAggregatedAssessedCompatibility.value - * ) - * }}} - */ - val fromAggregatedAssessedCompatibility = - Def.task { - val log = Keys.streams.value.log - val compatibility = aggregatedAssessedCompatibilityWithLatestRelease.value - log.debug(s"Aggregated compatibility level is ${compatibility}") - fromCompatibility(compatibility) - } - -} diff --git a/project/plugins.sbt b/project/plugins.sbt index 8d6a131..8d2c0cf 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -4,4 +4,4 @@ addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.21") -addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "2.1.3+16-9c3dded3+20231129-1538-SNAPSHOT") +addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "2.1.3+18-6e335734-SNAPSHOT")