Add sbt dynver

This commit is contained in:
Rohan Sircar 2021-04-18 11:22:52 +05:30
parent 5d12bdd3ce
commit 2ff30c8615
3 changed files with 24 additions and 10 deletions

View File

@ -95,8 +95,6 @@ jobs:
with: with:
username: rohansircar username: rohansircar
password: ${{ secrets.DOCKER_LOGIN_PASSWORD }} password: ${{ secrets.DOCKER_LOGIN_PASSWORD }}
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Migrate - name: Migrate
run: csbt flyway/flywayMigrate run: csbt flyway/flywayMigrate
- name: Publish - name: Publish

View File

@ -27,13 +27,22 @@ lazy val databaseUrl =
lazy val databaseUser = sys.env.getOrElse("CODEGEN_DB_USER", "test_user") lazy val databaseUser = sys.env.getOrElse("CODEGEN_DB_USER", "test_user")
lazy val databasePassword = sys.env.getOrElse("CODEGEN_DB_PASSWORD", "password") lazy val databasePassword = sys.env.getOrElse("CODEGEN_DB_PASSWORD", "password")
// alpine java docker image for smaller size - "azul/zulu-openjdk-alpine:11-jre-headless"
lazy val dockerJavaImage = lazy val dockerJavaImage =
sys.env.getOrElse("DOCKER_JAVA_IMAGE", "openjdk:11-jre-slim-buster") sys.env.getOrElse("DOCKER_JAVA_IMAGE", "openjdk:11-jre-slim-buster")
lazy val releaseVersion = sys.env.getOrElse("RELEASE_VERSION", "0.0.1-SNAPSHOT")
lazy val dockerPublishTag = sys.env // lazy val releaseVersion = {
.get("DOCKER_PUBLISH_TAG") // val str = sys.env.get("RELEASE_VERSION")
.orElse(sys.env.get("RELEASE_VERSION")) // str.map(s => if (s.startsWith("v")) s.tail else s)
.getOrElse("latest") // }
// lazy val dockerPublishTag = {
// val s = sys.env
// .get("DOCKER_PUBLISH_TAG")
// .orElse(sys.env.get("RELEASE_VERSION"))
// .getOrElse("latest")
// if (s.startsWith("v")) s.tail else s
// }
lazy val flyway = (project in file("modules/flyway")) lazy val flyway = (project in file("modules/flyway"))
.enablePlugins(FlywayPlugin) .enablePlugins(FlywayPlugin)
@ -51,9 +60,14 @@ lazy val root = (project in file("."))
.settings( .settings(
organization := "wow.doge", organization := "wow.doge",
name := "http4s-demo", name := "http4s-demo",
version := releaseVersion, // version := releaseVersion.getOrElse(dynver.value),
version in Docker := dockerPublishTag, version in Docker := sys.env
// alpine java docker image for smaller size - "azul/zulu-openjdk-alpine:11-jre-headless" .getOrElse(
"DOCKER_PUBLISH_TAG", {
val s = version.value
if (s.startsWith("v")) s.tail else s
}
),
dockerBaseImage := dockerJavaImage, dockerBaseImage := dockerJavaImage,
dockerExposedPorts := Seq(8081), dockerExposedPorts := Seq(8081),
dockerUsername := Some("rohansircar"), dockerUsername := Some("rohansircar"),

View File

@ -12,3 +12,5 @@ addSbtPlugin("com.github.tototoshi" % "sbt-slick-codegen" % "1.4.0")
addSbtPlugin("io.github.davidmweber" % "flyway-sbt" % "7.4.0") addSbtPlugin("io.github.davidmweber" % "flyway-sbt" % "7.4.0")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.23") addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.23")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.0") addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.0")
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.1.1")