Build snapshot container #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build snapshot container | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Which part of the version to increase (major, minor, patch)' | |
required: false | |
default: 'none' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ssh-key: ${{ secrets.SECRET_KEY }} | |
- name: Set Maven Project Version | |
id: set-version | |
run: | | |
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
echo "Current version: $current_version" | |
if [ "${{ github.event.inputs.version }}" == "none" ]; then | |
new_version="$current_version" | |
elif [ "${{ github.event.inputs.version }}" == "major" ]; then | |
new_version=$(echo $current_version | awk -F. -v OFS=. '{$1=$1+1; $2=0; $3=0; print $0"-SNAPSHOT"}') | |
elif [ "${{ github.event.inputs.version }}" == "minor" ]; then | |
new_version=$(echo $current_version | awk -F. -v OFS=. '{$2=$2+1; $3=0; print $0"-SNAPSHOT"}') | |
else | |
new_version=$(echo $current_version | awk -F. -v OFS=. '{$3=$3+1; print $0"-SNAPSHOT"}') | |
fi | |
echo "New version: $new_version" | |
mvn -B versions:set -DnewVersion=$new_version | |
mvn -B versions:set -DnewVersion=$new_version -DprocessAllModules | |
if [ "${{ github.event.inputs.version }}" != "none" ]; then | |
git config --global user.email "github-actions@github.com" | |
git config --global user.name "GitHub Actions" | |
git add pom.xml | |
git add **/pom.xml | |
git commit -m "Bump version to $new_version" | |
git push | |
fi | |
echo "::set-output name=new_version::$new_version" | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: "11" | |
distribution: "temurin" | |
cache: "maven" | |
- name: Set up Node 16 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Build with Maven | |
run: mvn -B verify "-Dspring-boot.run.jvmArguments=-Dfile.encoding=UTF-8" -DskipTests=true | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_KEY }} | |
- name: Build and push image | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
tags: itatm/dave-admin-portal:${{ steps.set-version.outputs.new_version }} | |
- name: Docker Hub Description | |
uses: peter-evans/dockerhub-description@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_KEY }} | |
repository: itatm/dave-admin-portal | |
short-description: Über das Adminportal können Zählstellen angelegt und bearbeitet werden. |