Skip to content

Fix github workflow

Fix github workflow #2

Workflow file for this run

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@v4
with:
name: keycloak-admin-events-logger-artifacts
path: target/*.jar