Release #4
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: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'debug' | |
type: choice | |
options: | |
- info | |
- warning | |
- debug | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: 'groot-mg/release/service-discovery' | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Build | |
run: ./gradlew :sd-app:build -x test | |
- name: Generate release version | |
run: ./gradlew :sd-app:release | |
- name: Upload JAR | |
uses: actions/upload-artifact@v4 | |
with: | |
name: app-jar | |
path: sd-app/build/libs/service-discovery.jar | |
publish-docker-image: | |
needs: build-and-release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Download JAR | |
uses: actions/download-artifact@v4 | |
with: | |
name: app-jar | |
path: sd-app/build/libs/ | |
- name: Get version | |
id: get_version | |
run: | | |
VERSION=$(./gradlew sd-app:currentVersion -q --console=plain | grep -oP '(?<=Project version: )[\d\.]+') | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=semver,prefix=v,pattern={{raw}},value=v${{ env.VERSION }} | |
- name: Build and push Docker image | |
id: push | |
uses: docker/build-push-action@v6 | |
with: | |
context: sd-app/ | |
push: true | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }} | |
labels: ${{ steps.meta.outputs.labels }} |