Skip to content

Create Release

Create Release #233

Workflow file for this run

name: Create Release
on:
push:
tags:
- 'v*'
jobs:
build:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cache SBT
uses: actions/cache@v3
with:
path: |
~/.ivy2/cache
~/.sbt
key: ${{ runner.os }}-sbt-${{ hashFiles('**/build.sbt') }}
- name: Setup Scala
uses: actions/setup-java@v3
with:
java-version: 17
distribution: corretto
- name: Test with Coverage / Static code analyse / Code style
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sbt \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.organization=gastonschabas \
-Dsonar.projectKey=gastonschabas_rumble-on-scala \
-Dsonar.sources=src/main/scala \
-Dsonar.tests=src/test/scala \
-Dsonar.scala.scalastyle.reportPaths=target/scalastyle-result.xml \
-Dsonar.scala.coverage.reportPaths=target/scala-2.13/scoverage-report/scoverage.xml \
clean compile coverage test it:test coverageReport scalastyle scalafmtCheckAll scalafmtSbtCheck sonarScan
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Docker Stage
run: sbt docker:stage
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Set Release Version in github env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Body Message for release extracted from commit message
run: echo "RELEASE_BODY_MSG=$(git log --skip 2 -1 --pretty=%B)" >> $GITHUB_ENV
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: ./target/docker/stage
file: ./target/docker/stage/Dockerfile
push: true
tags: |
gastonschabas/rumble-on-scala:${{ env.RELEASE_VERSION }}
gastonschabas/rumble-on-scala:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: |
Changes in this Release:
${{ env.RELEASE_BODY_MSG }}
draft: false
prerelease: false