Skip to content

Commit a62f1da

Browse files
Simplify CI (fix #76)
1 parent 46cf82e commit a62f1da

File tree

8 files changed

+112
-82
lines changed

8 files changed

+112
-82
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ matrix:
7474
before_script: ./checkCLA.sh
7575
script:
7676
- java -version
77-
- admin/build.sh
77+
- sbt ci
7878

7979
cache:
8080
directories:

admin/build.sh

Lines changed: 0 additions & 69 deletions
This file was deleted.

admin/gpg.sbt

Lines changed: 0 additions & 2 deletions
This file was deleted.

admin/pre-release.sh

Lines changed: 6 additions & 0 deletions
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

Lines changed: 0 additions & 8 deletions
This file was deleted.

build.sbt

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
230255
inThisBuild(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
))

project/Version.scala

Lines changed: 18 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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)