Skip to content

Commit

Permalink
Setup github action
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Dec 11, 2024
1 parent d760ba0 commit 9d96c12
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Create Release and Publish Artifacts

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout the code
uses: actions/checkout@v2

- name: Set up Java 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adoptopenjdk'

- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build with Maven
run: mvn clean install -DskipTests

- name: Extract version from pom.xml
id: version
run: |
VERSION=$(xmlstarlet sel -t -m "/project/version" -v . pom.xml)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Check if the version already exists
id: check_release
run: |
RELEASE_EXISTS=$(gh release view ${{ env.VERSION }} --json tagName --jq '.tagName' || echo "")
echo "Release exists: $RELEASE_EXISTS"
if [[ -n "$RELEASE_EXISTS" ]]; then
echo "Release already exists. Skipping..."
exit 0
fi
- name: Create GitHub Release
id: create_release
run: |
gh release create ${{ env.VERSION }} target/*.jar --title "Release ${{ env.VERSION }}" --notes "Release created automatically from GitHub Actions"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload JARs as artifacts
uses: actions/upload-artifact@v2
with:
name: keycloak-admin-events-logger-artifacts
path: target/*.jar

0 comments on commit 9d96c12

Please sign in to comment.