|
5 | 5 | branches: |
6 | 6 | - main |
7 | 7 | - master |
| 8 | + workflow_dispatch: |
8 | 9 |
|
9 | 10 | jobs: |
10 | 11 | build: |
11 | 12 | runs-on: ubuntu-latest |
| 13 | + |
12 | 14 | steps: |
| 15 | + # ── 1. Checkout ──────────────────────────────────────────────────────── |
13 | 16 | - name: Checkout source |
14 | | - uses: actions/checkout@v3 |
| 17 | + uses: actions/checkout@v4 |
15 | 18 |
|
16 | | - - name: Setup Node.js |
17 | | - uses: actions/setup-node@v3 |
| 19 | + # ── 2. Java 17 (wymagane przez AGP 8.x) ─────────────────────────────── |
| 20 | + - name: Setup Java 17 |
| 21 | + uses: actions/setup-java@v4 |
18 | 22 | with: |
19 | | - node-version: 18 |
20 | | - |
21 | | - - name: Install dependencies |
22 | | - working-directory: ./source-code |
23 | | - run: | |
24 | | - npm install |
25 | | - # Instalujemy narzędzie do generowania ikon, jeśli nie ma go w projekcie |
26 | | - npm install @capacitor/assets --save-dev |
27 | | -
|
28 | | - - name: Build Web Assets |
29 | | - working-directory: ./source-code |
30 | | - run: npm run build |
| 23 | + distribution: 'zulu' |
| 24 | + java-version: '17' |
31 | 25 |
|
32 | | - - name: Generate Android Icons and Splash |
33 | | - working-directory: ./source-code |
34 | | - # To narzędzie automatycznie wygeneruje ikony w android/app/src/main/res/ |
35 | | - # Upewnij się, że masz plik assets/icon-only.png lub assets/icon.png |
36 | | - run: npx capacitor-assets generate --android |
| 26 | + # ── 3. Gradle wrapper — pobiera gradle-wrapper.jar automatycznie ─────── |
| 27 | + - name: Setup Gradle |
| 28 | + uses: gradle/actions/setup-gradle@v3 |
| 29 | + with: |
| 30 | + gradle-version: '8.9' |
37 | 31 |
|
38 | | - - name: Setup Java |
39 | | - uses: actions/setup-java@v3 |
| 32 | + # ── 4. Cache Gradle ──────────────────────────────────────────────────── |
| 33 | + - name: Cache Gradle packages |
| 34 | + uses: actions/cache@v4 |
40 | 35 | with: |
41 | | - distribution: 'zulu' |
42 | | - java-version: '17' |
| 36 | + path: | |
| 37 | + ~/.gradle/caches |
| 38 | + ~/.gradle/wrapper |
| 39 | + key: gradle-${{ runner.os }}-${{ hashFiles('source-code/**/*.gradle.kts', 'source-code/**/libs.versions.toml') }} |
| 40 | + restore-keys: | |
| 41 | + gradle-${{ runner.os }}- |
43 | 42 |
|
44 | | - - name: Add and Sync Android |
| 43 | + # ── 5. Uprawnienia gradlew ───────────────────────────────────────────── |
| 44 | + - name: Grant execute permission for gradlew |
45 | 45 | working-directory: ./source-code |
46 | | - run: | |
47 | | - npx cap add android || echo "Android already added" |
48 | | - npx cap sync android |
| 46 | + run: chmod +x gradlew |
49 | 47 |
|
50 | | - - name: Build APK with Gradle |
51 | | - working-directory: ./source-code/android |
52 | | - run: | |
53 | | - chmod +x gradlew |
54 | | - ./gradlew assembleDebug |
| 48 | + # ── 6. Build Debug APK ───────────────────────────────────────────────── |
| 49 | + - name: Build Debug APK |
| 50 | + working-directory: ./source-code |
| 51 | + run: ./gradlew assembleDebug --no-daemon --stacktrace |
55 | 52 |
|
56 | | - - name: Upload APK |
| 53 | + # ── 7. Upload artefaktu ──────────────────────────────────────────────── |
| 54 | + - name: Upload Debug APK |
57 | 55 | uses: actions/upload-artifact@v4 |
58 | 56 | with: |
59 | | - name: hackeros-app-debug |
60 | | - path: source-code/android/app/build/outputs/apk/debug/app-debug.apk |
| 57 | + name: hackeros-app-debug-${{ github.sha }} |
| 58 | + path: source-code/app/build/outputs/apk/debug/app-debug.apk |
| 59 | + retention-days: 30 |
| 60 | + |
| 61 | + # ── 8. Info o APK ────────────────────────────────────────────────────── |
| 62 | + - name: Show APK info |
| 63 | + run: | |
| 64 | + APK="source-code/app/build/outputs/apk/debug/app-debug.apk" |
| 65 | + if [ -f "$APK" ]; then |
| 66 | + echo "✅ APK built successfully" |
| 67 | + echo "📦 Size: $(du -sh "$APK" | cut -f1)" |
| 68 | + else |
| 69 | + echo "❌ APK not found!" |
| 70 | + exit 1 |
| 71 | + fi |
0 commit comments