From d3f6d841bed8a9c2bae2e97ca968e3684583fae2 Mon Sep 17 00:00:00 2001 From: Mikhail Vorozhtsov Date: Sun, 24 Nov 2019 20:45:28 +0300 Subject: [PATCH] Add sonatypeReleaseBundleIfNotSnapshot to build.sbt --- .travis.yml | 2 +- build.sbt | 11 +++++++++++ project/plugins.sbt | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9647839..4cbc35a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,7 +43,7 @@ jobs: stage: publish name: "Publish" before_script: gpg --import project/ci.asc - script: sbt +publish sonatypeBundleRelease + script: sbt +publish sonatypeBundleReleaseIfNotSnapshot env: global: diff --git a/build.sbt b/build.sbt index d693853..17fc085 100644 --- a/build.sbt +++ b/build.sbt @@ -22,6 +22,17 @@ inThisBuild( ThisBuild / publishTo := sonatypePublishToBundle.value ThisBuild / publishMavenStyle := true +lazy val sonatypeBundleReleaseIfNotSnapshot = + taskKey[String]("Release a bundle to Sonatype (if not SNAPSHOT)") + +ThisBuild / sonatypeBundleReleaseIfNotSnapshot := Def.taskDyn { + if (isSnapshot.value) { + Def.task { "SNAPSHOT" } + } else { + Def.task { (sonatypeBundleRelease in publish).value } + } +}.value + inThisBuild( Seq( crossScalaVersions := Seq("2.13.1", "2.12.10", "2.11.12"), diff --git a/project/plugins.sbt b/project/plugins.sbt index 4eac55e..8a7775b 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,3 +1,3 @@ addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.2.1") addSbtPlugin("io.crashbox" % "sbt-gpg" % "0.2.0") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8.1")