Skip to content

Update build-apk.yml #101

Update build-apk.yml

Update build-apk.yml #101

Workflow file for this run

name: Build Android APK
on:
push:
branches:
- main
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
# ── 1. Checkout ────────────────────────────────────────────────────────
- name: Checkout source
uses: actions/checkout@v4
# ── 2. Java 17 (wymagane przez AGP 8.x) ───────────────────────────────
- name: Setup Java 17
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
# ── 3. Gradle wrapper — pobiera gradle-wrapper.jar automatycznie ───────
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: '8.9'
# ── 4. Cache Gradle ────────────────────────────────────────────────────
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: gradle-${{ runner.os }}-${{ hashFiles('source-code/**/*.gradle.kts', 'source-code/**/libs.versions.toml') }}
restore-keys: |
gradle-${{ runner.os }}-
# ── 5. Uprawnienia gradlew ─────────────────────────────────────────────
- name: Grant execute permission for gradlew
working-directory: ./source-code
run: chmod +x gradlew
# ── 6. Build Debug APK ─────────────────────────────────────────────────
- name: Build Debug APK
working-directory: ./source-code
run: ./gradlew assembleDebug --no-daemon --stacktrace
# ── 7. Upload artefaktu ────────────────────────────────────────────────
- name: Upload Debug APK
uses: actions/upload-artifact@v4
with:
name: hackeros-app-debug-${{ github.sha }}
path: source-code/app/build/outputs/apk/debug/app-debug.apk
retention-days: 30
# ── 8. Info o APK ──────────────────────────────────────────────────────
- name: Show APK info
run: |
APK="source-code/app/build/outputs/apk/debug/app-debug.apk"
if [ -f "$APK" ]; then
echo "✅ APK built successfully"
echo "📦 Size: $(du -sh "$APK" | cut -f1)"
else
echo "❌ APK not found!"
exit 1
fi