Skip to content

Commit 0b631f4

Browse files
authored
Merge pull request #454 from okibcn/DebugBuildPR
feat(ci): add automated debug APK build workflow with Gradle optimizations
2 parents 3f79fd9 + 71cb26f commit 0b631f4

3 files changed

Lines changed: 120 additions & 3 deletions

File tree

.github/workflows/debugBuild.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
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

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ android {
4444
if (System.getenv("MUSIC_DEBUG_SIGNING_STORE_PASSWORD") != null) {
4545
storeFile = file(System.getenv("MUSIC_DEBUG_KEYSTORE_FILE"))
4646
storePassword = System.getenv("MUSIC_DEBUG_SIGNING_STORE_PASSWORD")
47-
keyAlias = "debug"
47+
keyAlias = System.getenv("MUSIC_DEBUG_SIGNING_KEY_ALIAS") ?: "androiddebugkey"
4848
keyPassword = System.getenv("MUSIC_DEBUG_SIGNING_KEY_PASSWORD")
4949
}
5050
}

gradle.properties

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,31 @@
1212
# org.gradle.parallel=true
1313
#Sat Nov 19 15:59:34 CST 2022
1414

15-
org.gradle.jvmargs=-Xmx4096M -Dkotlin.daemon.jvm.options\="-Xmx4096M"
15+
# ------------------------------------------------------------
16+
# Rendimiento Gradle
17+
# ------------------------------------------------------------
18+
# Reutiliza salidas de tareas entre builds (local cache).
19+
org.gradle.caching=true
20+
21+
# Permite ejecución en paralelo cuando aplica (especialmente útil en multi-módulo).
22+
org.gradle.parallel=true
23+
24+
# Configuration Cache (estable). Acelera la fase de configuración en builds repetidos.
25+
org.gradle.configuration-cache=true
26+
# Modo tolerante mientras validas compatibilidad; si prefieres estricto, quita esta línea.
27+
org.gradle.configuration-cache.problems=warn
28+
29+
# JVM / Kotlin daemon
30+
org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8 -XX:+UseParallelGC -Dkotlin.daemon.jvm.options=-Xmx4g
31+
32+
# ------------------------------------------------------------
33+
# Android / Kotlin
34+
# ------------------------------------------------------------
1635
android.useAndroidX=true
1736
android.enableJetifier=true
18-
org.gradle.unsafe.configuration-cache=true
37+
38+
# Valores dependinetes del codigo (cambiarlos puede requerir ajustes en el código).
1939
android.nonTransitiveRClass=false
2040
android.nonFinalResIds=false
41+
42+
kotlin.code.style=official

0 commit comments

Comments
 (0)