Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI for publishing Docker image #133

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
19 changes: 17 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ jdk:
branches:
only:
- master
- /^v\d+\.\d+\.\d+$/

before_install:
- git fetch --tags

stages:
- name: test
- name: release
if: ((branch = master AND type = push) OR (tag IS present)) AND NOT fork

# https://www.scala-sbt.org/1.x/docs/Travis-CI-with-sbt.html
cache:
Expand All @@ -22,5 +31,11 @@ before_cache:
- find $HOME/.ivy2/cache -name "ivydata-*.properties" -print -delete
- find $HOME/.sbt -name "*.lock" -print -delete

script:
- sbt ++$TRAVIS_SCALA_VERSION ciBuild
jobs:
include:
# stage="test" if no stage is specified
- name: ciBuild
script: sbt ciBuild
# run ci-release only if previous stages passed
- stage: release
script: bash .travis/docker-login.sh && sbt ciRelease
2 changes: 2 additions & 0 deletions .travis/docker-login.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
echo "$GH_PAT" | docker login ghcr.io -u "$GH_USERNAME" --password-stdin
11 changes: 4 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import com.typesafe.sbt.packager.docker.Cmd
import Aliases._
import Release._

ThisBuild / scalafmtOnCompile := true
ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0"
ThisBuild / dynverSeparator := "-"

Global / onChangedBuildSource := ReloadOnSourceChanges

Expand All @@ -25,11 +25,11 @@ val compilerSettings = Seq(
)

lazy val dockerSettings = Seq(
Docker / packageName := "kafka-message-scheduler",
Docker / packageName := "sky-uk/kafka-message-scheduler",
dockerBaseImage := "eclipse-temurin:17-jdk-alpine",
dockerRepository := Some("skyuk"),
dockerRepository := Some("ghcr.io"),
dockerLabels := Map("maintainer" -> "Sky"),
dockerUpdateLatest := true,
dockerUpdateLatest := !isSnapshot.value,
dockerCommands ++= Seq(
Cmd("USER", "root"),
Cmd("RUN", "apk add --no-cache bash")
Expand All @@ -53,7 +53,6 @@ lazy val scheduler = (project in file("scheduler"))
javaAgents += "io.kamon" % "kanela-agent" % "1.0.14",
buildInfoSettings,
dockerSettings,
releaseSettings,
Test / parallelExecution := false
)

Expand All @@ -65,7 +64,6 @@ lazy val avro = (project in file("avro"))
.settings(libraryDependencies += Dependencies.avro4s)
.settings(schema := (Compile / run).toTask("").value)
.dependsOn(scheduler % "compile->compile")
.disablePlugins(ReleasePlugin)

lazy val root = (project in file("."))
.withId("kafka-message-scheduler")
Expand All @@ -74,4 +72,3 @@ lazy val root = (project in file("."))
.settings(dockerImageCreationTask := (scheduler / Docker / publishLocal).value)
.aggregate(scheduler, avro)
.enablePlugins(DockerComposePlugin)
.disablePlugins(ReleasePlugin)
2 changes: 1 addition & 1 deletion project/Aliases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object Aliases {

lazy val defineCommandAliases =
addCommandAlias("ciBuild", "checkFmt; checkFix; test; schema") ++
addCommandAlias("ciRelease", "clean; schema; project scheduler; release with-defaults") ++
addCommandAlias("ciRelease", "project scheduler; docker:publish") ++
bcarter97 marked this conversation as resolved.
Show resolved Hide resolved
addCommandAlias("checkFix", "scalafixAll --check OrganizeImports; scalafixAll --check") ++
addCommandAlias("runFix", "scalafixAll OrganizeImports; scalafixAll") ++
addCommandAlias("checkFmt", "scalafmtCheckAll; scalafmtSbtCheck") ++
Expand Down
37 changes: 0 additions & 37 deletions project/Release.scala

This file was deleted.

2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.11.0")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("com.lightbend.sbt" % "sbt-javaagent" % "0.1.6")
addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.9")
addSbtPlugin("com.tapad" % "sbt-docker-compose" % "1.0.35")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.0")
addSbtPlugin("io.kamon" % "sbt-kanela-runner" % "2.0.14")
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.3.1")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")
1 change: 0 additions & 1 deletion scheduler/version.sbt

This file was deleted.