Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save pandaforme/e378dc3f1f32aa252b14e40937491e9c to your computer and use it in GitHub Desktop.

Select an option

Save pandaforme/e378dc3f1f32aa252b14e40937491e9c to your computer and use it in GitHub Desktop.

Revisions

  1. pandaforme created this gist May 19, 2017.
    71 changes: 71 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    import sbt.Keys._
    import sbt._
    import sbtdocker.DockerPlugin.autoImport._
    import sbtrelease.ReleasePlugin.autoImport.ReleaseTransformations._

    lazy val resolversSettings = ...

    lazy val versions = ...

    lazy val dependenciesSettings = ...

    // Create a default Scala style task to run with compiles
    lazy val scalastyleCompile = taskKey[Unit]("Run scalastyle before compile")
    lazy val commonSettings = Seq(
    scalaVersion := "2.11.8",
    scalacOptions ++= Seq(
    "-deprecation",
    "-unchecked",
    "-encoding",
    "UTF-8",
    "-Xlint",
    "-Yclosure-elim",
    "-Yinline",
    "-Xverify",
    "-feature",
    "-language:postfixOps",
    "-target:jvm-1.8"
    ),
    resolvers ++= resolversSettings,
    libraryDependencies ++= dependenciesSettings,
    scalastyleCompile := scalastyle.in(Compile).toTask("").value,
    (scalastyleConfig in Compile) := file(
    s"${(resourceDirectory in Compile).value}/scalastyle-config.xml"),
    (compile in Compile) <<= (compile in Compile) dependsOn scalastyleCompile
    ) ++ scalafmtSettings

    lazy val dockerSettings = ...

    lazy val loginAwsEcr = TaskKey[Unit]("loginAwsEcr", "Login AWS ECR")
    loginAwsEcr := {
    import sys.process._
    Seq("bash", "(aws ecr get-login --region us-west-2)") !
    }

    lazy val publishDocker = ReleaseStep(action = st => {
    val extracted = Project.extract(st)
    val ref: ProjectRef = extracted.get(thisProjectRef)
    extracted.runAggregated(loginAwsEcr in ref, st)
    extracted.runAggregated(
    sbtdocker.DockerKeys.dockerBuildAndPush in sbtdocker.DockerPlugin.autoImport.docker in ref,
    st)
    st
    })

    lazy val releaseSettings = Seq(
    releaseProcess := Seq[ReleaseStep](
    checkSnapshotDependencies,
    inquireVersions,
    runTest,
    setReleaseVersion,
    commitReleaseVersion,
    publishDocker,
    setNextVersion,
    commitNextVersion
    ))

    lazy val root = Project(
    id = "root",
    base = file("."),
    settings = commonSettings ++ dockerSettings ++ releaseSettings
    ).enablePlugins(DockerPlugin)