@@ -226,11 +226,95 @@ lazy val scala213Settings = Seq(
226226 scalaVersion := scala213
227227)
228228
229+ val preRelease = " pre-release"
230+ val travisScalaVersion = sys.env.get(" TRAVIS_SCALA_VERSION" ).flatMap(Version .parse)
231+ val releaseVersion = sys.env.get(" TRAVIS_TAG" ).flatMap(Version .parse)
232+ val isScalaJs = sys.env.get(" SCALAJS_VERSION" ).nonEmpty
233+ val isScalafix = sys.env.get(" TEST_SCALAFIX" ).nonEmpty
234+ val isBinaryCompat = sys.env.get(" TEST_BINARY_COMPAT" ).nonEmpty
235+ val isRelease = releaseVersion.nonEmpty
236+
237+ val releaseCredentials =
238+ if (isRelease) {
239+ def env (key : String ): String = Option (System .getenv(key)).getOrElse(" " )
240+
241+ Seq (
242+ pgpPassphrase := Some (env(" PGP_PASSPHRASE" ).toArray),
243+ pgpPublicRing := file(" admin/pubring.asc" ),
244+ pgpSecretRing := file(" admin/secring.asc" ),
245+ credentials += Credentials (" Sonatype Nexus Repository Manager" , " oss.sonatype.org" , env(" SONA_USER" ), env(" SONA_PASS" ))
246+ )
247+ } else {
248+ Seq ()
249+ }
250+
251+ inThisBuild(releaseCredentials)
252+
253+
229254// required by sbt-scala-module
230255inThisBuild(Seq (
231256 crossScalaVersions := Seq (scala211, scala212, scala213),
232- commands += Command .command(" noop" ) { state =>
233- println(" noop" )
257+ commands += Command .command(preRelease) { state =>
258+ // Show Compat version, Scala version, and Java Version
259+ val jvmVersion = Version .parse(sys.props(" java.specification.version" )).get.minor
260+ val tagVersion = releaseVersion.get
261+ println(s " Releasing $tagVersion with Scala ${travisScalaVersion.get} on Java version $jvmVersion. " )
262+
263+ // Copy pgp stuff
264+ " admin/pre-release.sh" ! state.globalLogging.full
265+
234266 state
267+ },
268+ commands += Command .command(" ci" ) { state =>
269+ val platformSuffix = if (isScalaJs) " JS" else " "
270+
271+ val compatProject = " compat" + travisScalaVersion.get.binary + platformSuffix
272+ val binaryCompatProject = " binary-compat"
273+
274+ val testProjectPrefix =
275+ if (isScalafix) {
276+ " scalafix-tests"
277+ } else if (isBinaryCompat) {
278+ binaryCompatProject
279+ } else {
280+ compatProject
281+ }
282+
283+ val projectPrefix =
284+ if (isScalafix) {
285+ " scalafix-rules"
286+ } else if (isBinaryCompat) {
287+ binaryCompatProject
288+ } else {
289+ compatProject
290+ }
291+
292+ val setPublishVersion = releaseVersion.map(" set every version := " + _).toList
293+
294+ val publishTask =
295+ if (releaseVersion.nonEmpty) {
296+ List (
297+ preRelease,
298+ s " $projectPrefix/publish-signed "
299+ )
300+ } else {
301+ Nil
302+ }
303+
304+ val toRun = Seq (
305+ setPublishVersion,
306+ List (s " $projectPrefix/clean " ),
307+ List (s " $testProjectPrefix/test " ),
308+ List (s " $projectPrefix/publishLocal " ),
309+ publishTask
310+ ).flatten
311+
312+ println(" ---------" )
313+ println(" Running CI: " )
314+ toRun.foreach(println)
315+ println(" ---------" )
316+
317+
318+ toRun ::: state
235319 }
236320))
0 commit comments