From e1579733ee6835eaa5731f6b88cf74120bfed1a5 Mon Sep 17 00:00:00 2001 From: Pierre Andrews Date: Fri, 2 May 2014 12:39:29 -0300 Subject: [PATCH] add sbt-sonatype to do the release --- project/Build.scala | 44 +++++++++++++++++++++++++++++++++++++------- project/plugins.sbt | 4 +++- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 926112e..6fa9311 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1,5 +1,8 @@ import sbt._ import sbt.Keys._ +import com.typesafe.sbt.SbtPgp.PgpKeys.publishSigned + +import xerial.sbt.Sonatype.SonatypeKeys._ import sbtrelease.ReleaseStateTransformations._ import sbtrelease.ReleasePlugin.ReleaseKeys._ @@ -7,6 +10,7 @@ import sbtrelease.ReleasePlugin import sbtrelease.ReleaseStep import sbtrelease.Utilities._ import sbtrelease.Vcs +import sbtrelease.releaseTask import annotation.tailrec @@ -17,7 +21,11 @@ object SumacBuild extends Build { lazy val ext = Project("ext", file("ext"), settings = extSettings).settings(net.virtualvoid.sbt.graph.Plugin.graphSettings: _*) dependsOn(core) lazy val extZk = Project("ext-zk", file("ext-zk"), settings = extZkSettings).settings(net.virtualvoid.sbt.graph.Plugin.graphSettings: _*) dependsOn(core) - def sharedSettings = Defaults.defaultSettings ++ ReleasePlugin.releaseSettings ++ BranchRelease.branchSettings ++ Seq( + def sharedSettings = Defaults.defaultSettings ++ + ReleasePlugin.releaseSettings ++ + BranchRelease.branchSettings ++ + xerial.sbt.Sonatype.sonatypeSettings ++ + Seq( // version is managed by sbt-release in version.sbt scalaVersion := "2.11.0", organization := "com.quantifind", @@ -55,7 +63,8 @@ object SumacBuild extends Build { setReleaseVersion, BranchRelease.makeBranch, //make a new rel/$version branch commitReleaseVersion, // all changes happen here - publishArtifacts, + BranchRelease.publishSignedArtifacts, + releaseTask(sonatypeReleaseAll), BranchRelease.pushBranch, BranchRelease.moveToPreviousBranch, setNextVersion, // bump to the next snapshot version @@ -75,7 +84,7 @@ object SumacBuild extends Build { }, publishArtifact in Test := false, - + profileName := "com.quantifind", pomIncludeRepository := { x => false }, pomExtra := ( https://github.com/quantifind/Sumac @@ -103,10 +112,10 @@ object SumacBuild extends Build { http://github.com/ryanlecompte - pierre - Pierre Andrews - http://github.com/Mortimerp9 - + pierre + Pierre Andrews + http://github.com/Mortimerp9 + ), javacOptions ++= Seq("-target", "1.6", "-source", "1.6") ) //++ ScoverageSbtPlugin.instrumentSettings ++ CoverallsPlugin.coverallsSettings // waiting for 2.11.0 release @@ -262,6 +271,27 @@ object BranchRelease { branchName <<= (version in ThisBuild) map ( v => s"rel/$v" ) ) + ////////////////////////////////////////////////////////////////////// + // signed publish + ////////////////////////////////////////////////////////////////////// + + lazy val publishSignedArtifacts = ReleaseStep( + action = publishSignedArtifactsAction, + check = st => { + // getPublishTo fails if no publish repository is set up. + val ex = st.extract + val ref = ex.get(thisProjectRef) + Classpaths.getPublishTo(ex.get(publishTo in Global in ref)) + st + }, + enableCrossBuild = true + ) + private lazy val publishSignedArtifactsAction = { st: State => + val extracted = st.extract + val ref = extracted.get(thisProjectRef) + extracted.runAggregated(publishSigned in Global in ref, st) + } + } object BranchReleaseKeys { diff --git a/project/plugins.sbt b/project/plugins.sbt index 4d913c5..16a51c8 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,8 @@ resolvers += Resolver.url("sbt-plugin-releases", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns) -addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.1") + +addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1") addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.6.0")