-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ci-workflow.yml and create release.yml
- Loading branch information
1 parent
cd40c86
commit 0a1e2d2
Showing
2 changed files
with
112 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
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 }} |