Refactor PR build check workflow for improved readability and structure [skip ci]

This commit is contained in:
inventory69
2025-12-29 09:22:55 +01:00
parent 0bd686008d
commit 609da827c5

View File

@@ -1,27 +1,22 @@
name: PR Build Check name: PR Build Check
on: on:
pull_request: pull_request:
branches: [ main ] branches: [ main ]
paths: paths:
- 'android/**' - 'android/**'
- '.github/workflows/pr-build-check.yml' - '.github/workflows/pr-build-check.yml'
jobs: jobs:
build: build:
name: Build & Test APK name: Build & Test APK
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Code auschecken - name: Code auschecken
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Java einrichten - name: Java einrichten
uses: actions/setup-java@v4 uses: actions/setup-java@v4
with: with:
distribution: 'temurin' distribution: 'temurin'
java-version: '17' java-version: '17'
- name: Gradle Cache - name: Gradle Cache
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@@ -31,7 +26,6 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: | restore-keys: |
${{ runner.os }}-gradle- ${{ runner.os }}-gradle-
- name: Version auslesen - name: Version auslesen
run: | run: |
VERSION_NAME=$(grep "versionName = " android/app/build.gradle.kts | sed 's/.*versionName = "\(.*\)".*/\1/') VERSION_NAME=$(grep "versionName = " android/app/build.gradle.kts | sed 's/.*versionName = "\(.*\)".*/\1/')
@@ -39,18 +33,15 @@ jobs:
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
echo "📱 Version: $VERSION_NAME (Code: $VERSION_CODE)" echo "📱 Version: $VERSION_NAME (Code: $VERSION_CODE)"
- name: Debug Build erstellen (ohne Signing) - name: Debug Build erstellen (ohne Signing)
run: | run: |
cd android cd android
./gradlew assembleStandardDebug assembleFdroidDebug --no-daemon --stacktrace ./gradlew assembleStandardDebug assembleFdroidDebug --no-daemon --stacktrace
- name: Unit Tests ausfuehren - name: Unit Tests ausfuehren
run: | run: |
cd android cd android
./gradlew test --no-daemon --stacktrace ./gradlew test --no-daemon --stacktrace
continue-on-error: true continue-on-error: true
- name: Build-Ergebnis pruefen - name: Build-Ergebnis pruefen
run: | run: |
if [ -f "android/app/build/outputs/apk/standard/debug/app-standard-universal-debug.apk" ]; then if [ -f "android/app/build/outputs/apk/standard/debug/app-standard-universal-debug.apk" ]; then
@@ -60,7 +51,6 @@ jobs:
echo "❌ Standard Debug APK Build fehlgeschlagen" echo "❌ Standard Debug APK Build fehlgeschlagen"
exit 1 exit 1
fi fi
if [ -f "android/app/build/outputs/apk/fdroid/debug/app-fdroid-universal-debug.apk" ]; then if [ -f "android/app/build/outputs/apk/fdroid/debug/app-fdroid-universal-debug.apk" ]; then
echo "✅ F-Droid Debug APK erfolgreich gebaut" echo "✅ F-Droid Debug APK erfolgreich gebaut"
ls -lh android/app/build/outputs/apk/fdroid/debug/*.apk ls -lh android/app/build/outputs/apk/fdroid/debug/*.apk
@@ -68,7 +58,6 @@ jobs:
echo "❌ F-Droid Debug APK Build fehlgeschlagen" echo "❌ F-Droid Debug APK Build fehlgeschlagen"
exit 1 exit 1
fi fi
- name: Debug APKs hochladen (Artefakte) - name: Debug APKs hochladen (Artefakte)
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
@@ -77,7 +66,6 @@ jobs:
android/app/build/outputs/apk/standard/debug/*.apk android/app/build/outputs/apk/standard/debug/*.apk
android/app/build/outputs/apk/fdroid/debug/*.apk android/app/build/outputs/apk/fdroid/debug/*.apk
retention-days: 30 retention-days: 30
- name: Kommentar zu PR hinzufuegen - name: Kommentar zu PR hinzufuegen
uses: actions/github-script@v7 uses: actions/github-script@v7
if: success() if: success()
@@ -88,7 +76,6 @@ jobs:
.filter(f => f.endsWith('.apk')); .filter(f => f.endsWith('.apk'));
const fdroidApk = fs.readdirSync('android/app/build/outputs/apk/fdroid/debug/') const fdroidApk = fs.readdirSync('android/app/build/outputs/apk/fdroid/debug/')
.filter(f => f.endsWith('.apk')); .filter(f => f.endsWith('.apk'));
github.rest.issues.createComment({ github.rest.issues.createComment({
issue_number: context.issue.number, issue_number: context.issue.number,
owner: context.repo.owner, owner: context.repo.owner,
@@ -98,14 +85,13 @@ jobs:
**Version:** ${{ env.VERSION_NAME }} (Code: ${{ env.VERSION_CODE }}) **Version:** ${{ env.VERSION_NAME }} (Code: ${{ env.VERSION_CODE }})
### 📦 Debug APKs (Test-Builds) ### 📦 Debug APKs (Test-Builds)
Die Debug-APKs wurden erfolgreich gebaut und sind als Artefakte verfuegbar: Die Debug-APKs wurden erfolgreich gebaut und sind als Artefakte verfuegbar:
**Standard Flavor:** **Standard Flavor:**
${standardApk.map(f => '- `' + f + '`').join('\n')} ${standardApk.map(f => '- \`' + f + '\`').join('\n')}
**F-Droid Flavor:** **F-Droid Flavor:**
${fdroidApk.map(f => '- `' + f + '`').join('\n')} ${fdroidApk.map(f => '- \`' + f + '\`').join('\n')}
> ⚠️ **Hinweis:** Dies sind unsigned Debug-Builds zum Testen. Production Releases werden nur bei Merge auf \`main\` erstellt. > ⚠️ **Hinweis:** Dies sind unsigned Debug-Builds zum Testen. Production Releases werden nur bei Merge auf \`main\` erstellt.