-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (61 loc) · 2.01 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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: '17'
distribution: 'zulu'
- 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: Remove version number from jar
run: |
cd target
for file in *-[0-9]*.*.*.jar; do
mv "$file" "$(echo "$file" | sed -E 's/-[0-9]+\.[0-9]+\.[0-9]+\.jar$/.jar/')"
done
- name: Extract version from pom.xml using sed
id: version
run: |
VERSION=$(sed -n 's/.*<version>\([^<]*\)<\/version>.*/\1/p' pom.xml | head -n 1)
echo "Extracted VERSION: $VERSION"
if [[ -z "$VERSION" ]]; then
echo "Failed to extract version from pom.xml"
exit 1
fi
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