Skip to content

Commit badf309

Browse files
authored
Update gradle-build.yml
1 parent 0d5a58b commit badf309

1 file changed

Lines changed: 14 additions & 59 deletions

File tree

.github/workflows/gradle-build.yml

Lines changed: 14 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ jobs:
2323
packages: write
2424

2525
steps:
26-
- name: Checkout repository
27-
uses: actions/checkout@v4
26+
- uses: actions/checkout@v4
2827
with:
2928
fetch-depth: 0
3029

@@ -33,88 +32,44 @@ jobs:
3332
with:
3433
java-version: '21'
3534
distribution: 'temurin'
35+
cache: gradle
3636

3737
- name: Validate Gradle wrapper
3838
uses: gradle/wrapper-validation-action@v2
3939

40-
# Alternative caching strategy when GitHub cache fails
41-
- name: Cache Gradle dependencies
42-
uses: actions/cache@v4
43-
with:
44-
path: |
45-
~/.gradle/caches
46-
~/.gradle/wrapper
47-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
48-
restore-keys: |
49-
${{ runner.os }}-gradle-
50-
5140
- name: Setup Gradle
5241
uses: gradle/actions/setup-gradle@v3
53-
with:
54-
cache-disabled: false
55-
cache-read-only: ${{ github.event_name == 'pull_request' }}
56-
gradle-home-cache-cleanup: true
5742

5843
- name: Make Gradle wrapper executable
5944
run: chmod +x ./gradlew
6045

61-
# Combine build and test in one step to reduce overhead
62-
- name: Build and test with Gradle
63-
run: ./gradlew build --no-daemon --parallel --build-cache --configuration-cache
64-
env:
65-
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2g -XX:MaxMetaspaceSize=512m" -Dorg.gradle.daemon=false
46+
- name: Build with Gradle
47+
run: ./gradlew build --no-daemon
48+
49+
- name: Run tests
50+
run: ./gradlew test --no-daemon
6651

67-
- name: Extract version information
52+
- name: Extract version
6853
id: extract_version
6954
run: |
70-
# More robust version extraction that handles different formats
71-
if [ -f "build.gradle" ]; then
72-
VERSION=$(grep -E "version\s*=\s*['\"]" build.gradle | head -n 1 | sed -E "s/.*version\s*=\s*['\"]([^'\"]*)['\"].*/\1/")
73-
elif [ -f "build.gradle.kts" ]; then
74-
VERSION=$(grep -E "version\s*=\s*['\"]" build.gradle.kts | head -n 1 | sed -E "s/.*version\s*=\s*['\"]([^'\"]*)['\"].*/\1/")
75-
else
76-
VERSION="unknown"
77-
fi
78-
79-
if [ -z "$VERSION" ] || [ "$VERSION" = "unknown" ]; then
80-
VERSION="dev-$(date +%Y%m%d)"
81-
fi
82-
83-
COMMIT_SHA_SHORT=$(git rev-parse --short HEAD)
84-
55+
VERSION=$(grep 'version =' build.gradle | head -n 1 | awk -F "'" '{print $2}')
8556
echo "VERSION=$VERSION" >> $GITHUB_ENV
57+
COMMIT_SHA_SHORT=$(git rev-parse --short HEAD)
8658
echo "COMMIT_SHA_SHORT=$COMMIT_SHA_SHORT" >> $GITHUB_ENV
87-
echo "version=$VERSION" >> $GITHUB_OUTPUT
88-
echo "commit_sha_short=$COMMIT_SHA_SHORT" >> $GITHUB_OUTPUT
89-
9059
echo "Version: $VERSION (Commit: $COMMIT_SHA_SHORT)"
9160
9261
- name: Upload JAR artifact
9362
uses: actions/upload-artifact@v4
9463
with:
95-
name: SmartSpawner-${{ env.VERSION }}-${{ env.COMMIT_SHA_SHORT }}
96-
path: |
97-
core/build/libs/SmartSpawner-*.jar
98-
build/libs/SmartSpawner-*.jar
64+
name: SmartSpawner-${{ env.VERSION }}
65+
path: core/build/libs/SmartSpawner-${{ env.VERSION }}.jar
9966
retention-days: 90
100-
if-no-files-found: warn
67+
if-no-files-found: error
10168

10269
- name: Upload test reports on failure
10370
if: failure()
10471
uses: actions/upload-artifact@v4
10572
with:
10673
name: test-reports-${{ env.COMMIT_SHA_SHORT }}
107-
path: |
108-
**/build/reports/tests/
109-
**/build/test-results/
74+
path: build/reports/tests/
11075
retention-days: 7
111-
if-no-files-found: ignore
112-
113-
# Optional: Add summary for better visibility
114-
- name: Build Summary
115-
if: always()
116-
run: |
117-
echo "## Build Summary" >> $GITHUB_STEP_SUMMARY
118-
echo "- **Version**: ${{ env.VERSION }}" >> $GITHUB_STEP_SUMMARY
119-
echo "- **Commit**: ${{ env.COMMIT_SHA_SHORT }}" >> $GITHUB_STEP_SUMMARY
120-
echo "- **Status**: ${{ job.status }}" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)