From d1143994e37e517ff16126e9708b3c7caa9895cf Mon Sep 17 00:00:00 2001 From: Julien Richard-Foy Date: Wed, 29 Nov 2023 16:03:19 +0100 Subject: [PATCH] Simplify release process with https://github.com/scalacenter/sbt-version-policy/pull/186 --- build.sbt | 67 ++++++++++++++------------------------------- project/plugins.sbt | 2 +- 2 files changed, 22 insertions(+), 47 deletions(-) diff --git a/build.sbt b/build.sbt index 940543c..641acfd 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,5 @@ import ReleaseTransformations.* +import sbtversionpolicy.SbtVersionPolicyPlugin.aggregatedAssessedCompatibilityWithLatestRelease ThisBuild / scalaVersion := "2.13.12" ThisBuild / crossScalaVersions := Seq( @@ -54,57 +55,31 @@ 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 := Def.taskDyn { + releaseVersion := { import sbtrelease.{ Version, versionFormatError } val log = streams.value.log - val subprojectRefs = thisProject.value.aggregate + val compatibility = aggregatedAssessedCompatibilityWithLatestRelease.value - Def.taskDyn { - val compatibilityTask = - subprojectRefs.foldLeft(Def.task[Compatibility] { - Compatibility.BinaryAndSourceCompatible - }) { (previousCompatibilityTask, subproject) => - Def.task { - val previousCompatibility = previousCompatibilityTask.value - val subprojectCompatibilities = (subproject / versionPolicyAssessCompatibility).value - subprojectCompatibilities.headOption match { - case Some((_, compatibility)) => - log.debug(s"Compatibility of project ${subproject.project} is ${compatibility}") - (previousCompatibility, compatibility) match { - case (Compatibility.None, _) => Compatibility.None - case (_, Compatibility.None) => Compatibility.None - case (Compatibility.BinaryCompatible, _) => Compatibility.BinaryCompatible - case (_, Compatibility.BinaryCompatible) => Compatibility.BinaryCompatible - case _ => Compatibility.BinaryAndSourceCompatible - } - case None => previousCompatibility - } - } - } - Def.task { - val compatibility = compatibilityTask.value - log.info(s"Overall compatibility is ${compatibility}") - 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 - } - log.debug(s"releaseVersion function will apply ${maybeBump}") - ({ (currentVersion: String) => - val versionWithoutQualifier = - Version(currentVersion) - .getOrElse(versionFormatError(currentVersion)) - .withoutQualifier - (maybeBump match { - case Some(bump) => versionWithoutQualifier.bump(bump) - case None => versionWithoutQualifier - }).string - }) + log.info(s"Overall compatibility is ${compatibility}") + 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 } - } - }.value, + log.debug(s"releaseVersion function will apply ${maybeBump}") + ({ (currentVersion: String) => + val versionWithoutQualifier = + Version(currentVersion) + .getOrElse(versionFormatError(currentVersion)) + .withoutQualifier + (maybeBump match { + case Some(bump) => versionWithoutQualifier.bump(bump) + case None => versionWithoutQualifier + }).string + }) + }, releaseProcess := Seq[ReleaseStep]( checkSnapshotDependencies, inquireVersions, diff --git a/project/plugins.sbt b/project/plugins.sbt index 51909e2..8d6a131 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+14-700cfa17-SNAPSHOT") +addSbtPlugin("ch.epfl.scala" % "sbt-version-policy" % "2.1.3+16-9c3dded3+20231129-1538-SNAPSHOT")