diff --git a/.github/release-drafter.yaml b/.github/release-drafter.yaml new file mode 100644 index 000000000..27bcee3fb --- /dev/null +++ b/.github/release-drafter.yaml @@ -0,0 +1,4 @@ +template: | + ## What’s Changed + + $CHANGES diff --git a/.github/workflows/bootzooka-helm-ci.yaml b/.github/workflows/bootzooka-helm-ci.yaml index 0ff317bd9..d3afad250 100644 --- a/.github/workflows/bootzooka-helm-ci.yaml +++ b/.github/workflows/bootzooka-helm-ci.yaml @@ -5,6 +5,8 @@ on: paths: - "helm/**" - ".github/**" + branches: + - master pull_request: paths: - "helm/**" @@ -12,8 +14,6 @@ on: jobs: lint-chart: - # run on external PRs, but not on internal PRs since those will be run by push to branch - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository name: Lint Helm Chart runs-on: ubuntu-18.04 steps: @@ -86,6 +86,8 @@ jobs: run: git diff --exit-code publish-chart: + # run only on push to master + if: github.event_name == 'push' needs: - lint-chart - install-test-chart diff --git a/.github/workflows/bootzooka-scala-ts-ci.yml b/.github/workflows/bootzooka-scala-ts-ci.yml index d49bf7a38..9e59f28f2 100644 --- a/.github/workflows/bootzooka-scala-ts-ci.yml +++ b/.github/workflows/bootzooka-scala-ts-ci.yml @@ -1,18 +1,22 @@ name: Bootzooka CI on: + pull_request: push: + tags: [v*] + branches: + - master paths-ignore: - "helm/**" - pull_request: + release: + types: + - released paths-ignore: - "helm/**" jobs: - scala-ts-tests: - # run on external PRs, but not on internal PRs since those will be run by push to branch - if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository - name: CI + test: + name: Test runs-on: ubuntu-18.04 steps: @@ -39,3 +43,51 @@ jobs: - name: Run tests id: run-tests run: sbt test + + deploy: + if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/tags/v') + needs: [ test ] + runs-on: ubuntu-latest + + steps: + - name: Check-out repository + id: repo-checkout + uses: actions/checkout@v2 + + - name: Set up JDK 11 + id: jdk-setup + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Cache SBT + id: cache-sbt + uses: actions/cache@v2 + with: + path: | + ~/.sbt + ~/.ivy2/cache + ~/.coursier + key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }} + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract version + run: | + version=${GITHUB_REF/refs\/tags\/v/} + echo "VERSION=$version" >> $GITHUB_ENV + - name: Publish release notes + uses: release-drafter/release-drafter@v5 + with: + config-name: release-drafter.yml + publish: true + name: "v${{ env.VERSION }}" + tag: "v${{ env.VERSION }}" + version: "v${{ env.VERSION }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish docker image + run: sbt docker:publish diff --git a/build.sbt b/build.sbt index 26e77c932..e58643d58 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,6 @@ import sbtbuildinfo.BuildInfoKey.action import sbtbuildinfo.BuildInfoKeys.{buildInfoKeys, buildInfoOptions, buildInfoPackage} import sbtbuildinfo.{BuildInfoKey, BuildInfoOption} -import com.typesafe.sbt.packager.docker.ExecCmd import sbt._ import Keys._ @@ -156,29 +155,23 @@ lazy val fatJarSettings = Seq( } ) + lazy val dockerSettings = Seq( dockerExposedPorts := Seq(8080), dockerBaseImage := "adoptopenjdk:11.0.5_10-jdk-hotspot", Docker / packageName := "bootzooka", dockerUsername := Some("softwaremill"), - dockerCommands := { - dockerCommands.value.flatMap { - case ep @ ExecCmd("ENTRYPOINT", _*) => - Seq( - ExecCmd("ENTRYPOINT", "/opt/docker/docker-entrypoint.sh" :: ep.args.toList: _*) - ) - case other => Seq(other) - } - }, - Docker / mappings ++= { - val scriptDir = baseDirectory.value / ".." / "scripts" - val entrypointScript = scriptDir / "docker-entrypoint.sh" - val entrypointScriptTargetPath = "/opt/docker/docker-entrypoint.sh" - Seq(entrypointScript -> entrypointScriptTargetPath) - }, dockerUpdateLatest := true, Docker / publishLocal := (Docker / publishLocal).dependsOn(copyWebapp).value, - Docker / version := git.gitHeadCommit.value.map(head => now() + "-" + head.take(8)).getOrElse("latest") + Docker / version := git.gitDescribedVersion.value.getOrElse(git.formattedShaVersion.value.getOrElse("latest")), + git.uncommittedSignifier := Some("dirty"), + ThisBuild / git.formattedShaVersion := { + val base = git.baseVersion.?.value + val suffix = git.makeUncommittedSignifierSuffix(git.gitUncommittedChanges.value, git.uncommittedSignifier.value) + git.gitHeadCommit.value.map { sha => + git.defaultFormatShaVersion(base, sha.take(7), suffix) + } + } ) def haltOnCmdResultError(result: Int) { diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh deleted file mode 100755 index 5db81e7fd..000000000 --- a/scripts/docker-entrypoint.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -set -x - -CGROUP_MEMORY_LIMIT_FILE="/sys/fs/cgroup/memory/memory.limit_in_bytes" -if [ -f $CGROUP_MEMORY_LIMIT_FILE ]; then - MAXRAM=$(cat ${CGROUP_MEMORY_LIMIT_FILE}) -else - echo "This script is designed to run inside docker only, exiting..." - exit 1 -fi - -TOTAL_MEMORY=$(($(cat /proc/meminfo |head -n 1 |awk '{print $2}')*1024)) - -if [ "${MAXRAM}" -lt "${TOTAL_MEMORY}" ]; then - XMXPERCENT="${XMXPERCENT:-80}" - XMX=$(($MAXRAM-$MAXRAM/100*(100-$XMXPERCENT))) - XMX_CONFIG="-J-Xmx${XMX} -J-Xms${XMX}" -fi - -LOG_LEVEL="${LOG_LEVEL:-INFO}" - -[ "${LOG_HOST}" -a "${LOG_PORT}" ] && LOGGING_CONFIG="-DLOG_HOST=${LOG_HOST} -DLOG_PORT=${LOG_PORT} -DAPP_ENV=${APP_ENV} -DAPP_NAME=${APP_NAME} -DSERVICE_INSTANCE_ID=${SERVICE_INSTANCE_ID} -DHOST_ID=${HOST_ID} -DLOG_LEVEL=${LOG_LEVEL}" - -echo "Starting the JVM process" -command="$@" -exec $command ${LOGGING_CONFIG} ${XMX_CONFIG} diff --git a/version.sbt b/version.sbt index de734f78f..a3a28d6cf 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "0.0.1-SNAPSHOT" +ThisBuild / version := "0.0.1-SNAPSHOT"