Skip to content

Commit 08cd63d

Browse files
Simplify CI (fix scala#76)
1 parent d231e80 commit 08cd63d

File tree

8 files changed

+109
-79
lines changed

8 files changed

+109
-79
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ matrix:
6969
before_script: ./checkCLA.sh
7070
script:
7171
- java -version
72-
- admin/build.sh
72+
- sbt ci
7373

7474
cache:
7575
directories:

admin/build.sh

-65
This file was deleted.

admin/gpg.sbt

-2
This file was deleted.

admin/pre-release.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
# Copied from the output of genKeyPair.sh
4+
K=$encrypted_8c7005201bb0_key
5+
IV=$encrypted_8c7005201bb0_iv
6+
openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d

admin/publish-settings.sbt

-8
This file was deleted.

build.sbt

+83-3
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,91 @@ lazy val scala213Settings = Seq(
194194
scalaVersion := scala213
195195
)
196196

197+
val preRelease = "pre-release"
198+
val travisScalaVersion = sys.env.get("TRAVIS_SCALA_VERSION").flatMap(Version.parse)
199+
val releaseVersion = sys.env.get("TRAVIS_TAG").flatMap(Version.parse)
200+
val isScalaJs = sys.env.get("SCALAJS_VERSION").nonEmpty
201+
val isScalafix = sys.env.get("TEST_SCALAFIX").nonEmpty
202+
val isRelease = releaseVersion.nonEmpty
203+
204+
205+
val releaseCredentials =
206+
if (isRelease) {
207+
def env(key: String): String = Option(System.getenv(key)).getOrElse("")
208+
209+
Seq(
210+
pgpPassphrase := Some(env("PGP_PASSPHRASE").toArray),
211+
pgpPublicRing := file("admin/pubring.asc"),
212+
pgpSecretRing := file("admin/secring.asc"),
213+
credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", env("SONA_USER"), env("SONA_PASS"))
214+
)
215+
} else {
216+
Seq()
217+
}
218+
219+
inThisBuild(releaseCredentials)
220+
221+
197222
// required by sbt-scala-module
198223
inThisBuild(Seq(
199224
crossScalaVersions := Seq(scala211, scala212, scala213),
200-
commands += Command.command("noop") { state =>
201-
println("noop")
225+
commands += Command.command(preRelease) { state =>
226+
// Show Compat version, Scala version, and Java Version
227+
val jvmVersion = Version.parse(sys.props("java.specification.version")).get.minor
228+
val tagVersion = releaseVersion.get
229+
println(s"Releasing $tagVersion with Scala ${travisScalaVersion.get} on Java version $jvmVersion.")
230+
231+
// Copy pgp stuff
232+
"admin/pre-release.sh" ! state.globalLogging.full
233+
202234
state
235+
},
236+
commands += Command.command("ci") { state =>
237+
val platformSuffix = if (isScalaJs) "JS" else ""
238+
239+
val compatProject =
240+
"compat" + travisScalaVersion.get.binary + platformSuffix
241+
242+
val testProjectPrefix =
243+
if (isScalafix) {
244+
"scalafix-tests"
245+
} else {
246+
compatProject
247+
}
248+
249+
val projectPrefix =
250+
if (isScalafix) {
251+
"scalafix-rules"
252+
} else {
253+
compatProject
254+
}
255+
256+
val setPublishVersion = releaseVersion.map("set every version := " + _).toList
257+
258+
val publishTask =
259+
if (releaseVersion.nonEmpty) {
260+
List(
261+
preRelease,
262+
s"$projectPrefix/publish-signed"
263+
)
264+
} else {
265+
Nil
266+
}
267+
268+
val toRun = Seq(
269+
setPublishVersion,
270+
List(s"$projectPrefix/clean"),
271+
List(s"$testProjectPrefix/test"),
272+
List(s"$projectPrefix/publishLocal"),
273+
publishTask
274+
).flatten
275+
276+
println("---------")
277+
println("Running CI: ")
278+
toRun.foreach(println)
279+
println("---------")
280+
281+
282+
toRun ::: state
203283
}
204-
))
284+
))

project/Version.scala

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
case class Version(major: Int, minor: Int, patch: Int) {
2+
def binary: String = s"${major}${minor}"
3+
override def toString: String = s"${major}.${minor}.${patch}"
4+
}
5+
6+
object Version {
7+
private val versionRegex0 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)".r
8+
private val versionRegex1 = "v?([0-9]+)\\.([0-9]+)\\.([0-9]+)-M([0-9]+)".r
9+
private val versionRegex2 = "([0-9]+)\\.([0-9]+)".r
10+
def parse(raw: String): Option[Version] = {
11+
raw match {
12+
case versionRegex0(major, minor, patch) => Some(Version(major.toInt, minor.toInt, patch.toInt))
13+
case versionRegex1(major, minor, patch, _) => Some(Version(major.toInt, minor.toInt, patch.toInt))
14+
case versionRegex2(major, minor) => Some(Version(major.toInt, minor.toInt, 0))
15+
case _ => None
16+
}
17+
}
18+
}

project/plugins.sbt

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.5.0")
1212
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.14")
1313
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.5.10")
1414
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")
15+
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3")

0 commit comments

Comments
 (0)