|
| 1 | +name: Debug Build |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: "build" |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + paths-ignore: |
| 10 | + - '*.md' |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + |
| 18 | + # ── 1. CHECKOUT ──────────────────────────────────────────────────────────── |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + submodules: recursive |
| 23 | + fetch-depth: 1 |
| 24 | + |
| 25 | + # ── 2. PERMISOS ──────────────────────────────────────────────────────────── |
| 26 | + - name: Grant execute permission for gradlew |
| 27 | + run: chmod +x gradlew |
| 28 | + |
| 29 | + # ── 3. JDK ───────────────────────────────────────────────────────────────── |
| 30 | + - name: Set up JDK 21 |
| 31 | + uses: actions/setup-java@v4 |
| 32 | + with: |
| 33 | + distribution: temurin |
| 34 | + java-version: 21 |
| 35 | + |
| 36 | + # ── 4. GRADLE CACHE ──────────────────────────────────────────────────────── |
| 37 | + - name: Setup Gradle |
| 38 | + uses: gradle/actions/setup-gradle@v4 |
| 39 | + with: |
| 40 | + cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} |
| 41 | + cache-read-only: false |
| 42 | + |
| 43 | + # ── 5. SIGNING ───────────────────────────────────────────────────────────── |
| 44 | + # - Si DEBUG_KEYSTORE_BASE64 existe → lo decodifica y lo usa (firma consistente) |
| 45 | + # - Si no existe → genera uno aleatorio con aviso (firma efímera) |
| 46 | + # En ambos casos termina con los env vars de firma configurados. |
| 47 | + - name: Setup debug keystore & signing env vars |
| 48 | + env: |
| 49 | + KEYSTORE_SECRET: ${{ secrets.DEBUG_KEYSTORE_BASE64 }} |
| 50 | + run: | |
| 51 | + mkdir -p "$RUNNER_TEMP/keystore/" |
| 52 | + if [ -n "$KEYSTORE_SECRET" ]; then |
| 53 | + printf '%s' "$KEYSTORE_SECRET" | base64 -d > "$RUNNER_TEMP/keystore/prerelease.keystore" |
| 54 | + echo "✅ Keystore cargado desde DEBUG_KEYSTORE_BASE64" |
| 55 | + else |
| 56 | + keytool -genkey -v \ |
| 57 | + -keystore "$RUNNER_TEMP/keystore/prerelease.keystore" \ |
| 58 | + -storepass android \ |
| 59 | + -keypass android \ |
| 60 | + -alias androiddebugkey \ |
| 61 | + -keyalg RSA -keysize 2048 -validity 10000 \ |
| 62 | + -dname "C=US, O=Android, CN=Android Debug" |
| 63 | + echo "" |
| 64 | + echo "════════════════════════════════════════════════════════" |
| 65 | + echo "⚠️ DEBUG_KEYSTORE_BASE64 no está configurado." |
| 66 | + echo " Este APK usa una firma aleatoria — no podrás instalar" |
| 67 | + echo " esta build sobre una anterior sin desinstalarla antes." |
| 68 | + echo "" |
| 69 | + echo " Para fijar esta firma de forma permanente, copia el" |
| 70 | + echo " bloque de abajo y añádelo en:" |
| 71 | + echo " Settings → Secrets and variables → Actions → [New Repository Secret]" |
| 72 | + echo " Nombre del secret: DEBUG_KEYSTORE_BASE64" |
| 73 | + echo "════════════════════════════════════════════════════════" |
| 74 | + base64 "$RUNNER_TEMP/keystore/prerelease.keystore" |
| 75 | + echo "════════════════════════════════════════════════════════" |
| 76 | + fi |
| 77 | + echo "MUSIC_DEBUG_KEYSTORE_FILE=$RUNNER_TEMP/keystore/prerelease.keystore" >> $GITHUB_ENV |
| 78 | + echo "MUSIC_DEBUG_SIGNING_STORE_PASSWORD=android" >> $GITHUB_ENV |
| 79 | + echo "MUSIC_DEBUG_SIGNING_KEY_PASSWORD=android" >> $GITHUB_ENV |
| 80 | + echo "MUSIC_DEBUG_SIGNING_KEY_ALIAS=androiddebugkey" >> $GITHUB_ENV |
| 81 | +
|
| 82 | + # ── 6. BUILD ─────────────────────────────────────────────────────────────── |
| 83 | + # --build-cache → reutiliza outputs de tareas cacheadas |
| 84 | + # --configuration-cache → cachea la fase de configuración de Gradle |
| 85 | + # --parallel → ejecuta tareas independientes en paralelo |
| 86 | + - name: Build Debug APK |
| 87 | + run: ./gradlew assembleDebug --build-cache --configuration-cache --parallel |
| 88 | + |
| 89 | + # ── 7. ARTIFACT ──────────────────────────────────────────────────────────── |
| 90 | + - name: Upload Debug APK |
| 91 | + uses: actions/upload-artifact@v4 |
| 92 | + with: |
| 93 | + name: debug-apk-${{ github.ref_name }}-run${{ github.run_number }} |
| 94 | + path: "app/build/outputs/apk/debug/*.apk" |
| 95 | + retention-days: 7 |
0 commit comments