Release #2
Workflow file for this run
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/gateway' | |
jobs: | |
build-and-release: | |
if: github.ref == 'refs/heads/main' | |
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 :app:build -x test | |
- name: Generate release version | |
run: ./gradlew :app:release | |
- name: Set repository basename | |
id: set-basename | |
run: echo "REPO_BASENAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV | |
- name: Upload JAR | |
uses: actions/upload-artifact@v4 | |
with: | |
name: app-jar | |
path: app/build/libs/${{ env.REPO_BASENAME }}.jar | |
publish-docker-image: | |
if: github.ref == 'refs/heads/main' | |
needs: 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: Download JAR | |
uses: actions/download-artifact@v4 | |
with: | |
name: app-jar | |
path: app/build/libs/ | |
- name: Get version | |
id: get_version | |
run: | | |
VERSION=$(./gradlew 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: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set repository basename | |
id: set-basename | |
run: echo "REPO_BASENAME=$(basename ${{ github.repository }})" >> $GITHUB_ENV | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/groot-mg/release/${{ env.BASE_NAME }} | |
tags: | | |
type=semver,prefix=v,pattern={{raw}},value=${{ env.VERSION }} | |
- name: Build and push Docker image | |
id: push | |
uses: docker/build-push-action@v6 | |
with: | |
context: app/ | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |