ci: build only unsigned debug apks on PR

This commit is contained in:
Kavish Devar
2026-05-11 21:08:49 +05:30
parent c15e15a6b7
commit 6f28df734e
2 changed files with 43 additions and 9 deletions

View File

@@ -35,6 +35,7 @@ jobs:
java-version: 21 java-version: 21
- uses: gradle/actions/setup-gradle@v4 - uses: gradle/actions/setup-gradle@v4
- name: Decode keystore - name: Decode keystore
if: github.event_name != 'pull_request'
run: echo "${{ secrets.RELEASE_KEYSTORE_FILE }}" | base64 --decode > android/release.keystore run: echo "${{ secrets.RELEASE_KEYSTORE_FILE }}" | base64 --decode > android/release.keystore
- name: Setup Android SDK - name: Setup Android SDK
uses: android-actions/setup-android@v3 uses: android-actions/setup-android@v3
@@ -43,6 +44,7 @@ jobs:
- name: Install NDK - name: Install NDK
run: sdkmanager "ndk;30.0.14904198" run: sdkmanager "ndk;30.0.14904198"
- name: Create local.properties - name: Create local.properties
if: github.event_name != 'pull_request'
run: | run: |
cat <<EOF > android/local.properties cat <<EOF > android/local.properties
RELEASE_STORE_FILE=../release.keystore RELEASE_STORE_FILE=../release.keystore
@@ -50,7 +52,12 @@ jobs:
RELEASE_KEY_ALIAS=${{ secrets.RELEASE_KEY_ALIAS }} RELEASE_KEY_ALIAS=${{ secrets.RELEASE_KEY_ALIAS }}
RELEASE_KEY_PASSWORD=${{ secrets.RELEASE_KEY_PASSWORD }} RELEASE_KEY_PASSWORD=${{ secrets.RELEASE_KEY_PASSWORD }}
EOF EOF
- name: Build - name: Build debug APK for PRs
if: github.event_name == 'pull_request'
run: ./gradlew assembleFossDebug
working-directory: android
- name: Build release artifacts
if: github.event_name != 'pull_request'
run: ./gradlew packageReleaseArtifacts run: ./gradlew packageReleaseArtifacts
working-directory: android working-directory: android
- name: Get app version - name: Get app version
@@ -59,26 +66,37 @@ jobs:
- id: vars - id: vars
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: github.event_name != 'pull_request'
with: with:
name: apk-release name: apk-release
path: release/*release.apk path: release/*release.apk
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: github.event_name == 'pull_request'
with:
name: apk-debug
path: android/app/build/outputs/apk/foss/debug/app-foss-debug.apk
- uses: actions/upload-artifact@v4
if: github.event_name != 'pull_request'
with: with:
name: apk-debug name: apk-debug
path: release/*debug.apk path: release/*debug.apk
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: github.event_name != 'pull_request'
with: with:
name: root-module-release name: root-module-release
path: release/*release.zip path: release/*release.zip
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: github.event_name != 'pull_request'
with: with:
name: root-module-debug name: root-module-debug
path: release/*debug.zip path: release/*debug.zip
- uses: actions/upload-artifact@v4 - uses: actions/upload-artifact@v4
if: github.event_name != 'pull_request'
with: with:
name: release-bundle name: release-bundle
path: release/*.aab path: release/*.aab

View File

@@ -10,17 +10,29 @@ plugins {
id("kotlin-parcelize") id("kotlin-parcelize")
} }
val localPropsFile = rootProject.file("local.properties")
val props = Properties().apply { val props = Properties().apply {
load(rootProject.file("local.properties").inputStream()) if (localPropsFile.exists()) {
load(localPropsFile.inputStream())
}
} }
val releaseSigningAvailable = listOf(
"RELEASE_STORE_FILE",
"RELEASE_STORE_PASSWORD",
"RELEASE_KEY_ALIAS",
"RELEASE_KEY_PASSWORD"
).all { props[it]?.toString()?.isNotBlank() == true }
android { android {
signingConfigs { signingConfigs {
create("release") { if (releaseSigningAvailable) {
storeFile = file(props["RELEASE_STORE_FILE"] as String) create("release") {
storePassword = props["RELEASE_STORE_PASSWORD"] as String storeFile = file(props["RELEASE_STORE_FILE"] as String)
keyAlias = props["RELEASE_KEY_ALIAS"] as String storePassword = props["RELEASE_STORE_PASSWORD"] as String
keyPassword = props["RELEASE_KEY_PASSWORD"] as String keyAlias = props["RELEASE_KEY_ALIAS"] as String
keyPassword = props["RELEASE_KEY_PASSWORD"] as String
}
} }
} }
namespace = "me.kavishdevar.librepods" namespace = "me.kavishdevar.librepods"
@@ -45,14 +57,18 @@ android {
} }
} }
buildConfigField("Boolean", "PLAY_BUILD", "false") buildConfigField("Boolean", "PLAY_BUILD", "false")
signingConfig = signingConfigs.getByName("release") if (releaseSigningAvailable) {
signingConfig = signingConfigs.getByName("release")
}
defaultConfig { defaultConfig {
minSdk = 33 minSdk = 33
} }
} }
debug { debug {
buildConfigField("Boolean", "PLAY_BUILD", "false") buildConfigField("Boolean", "PLAY_BUILD", "false")
signingConfig = signingConfigs.getByName("release") if (releaseSigningAvailable) {
signingConfig = signingConfigs.getByName("release")
}
versionNameSuffix = "-debug" versionNameSuffix = "-debug"
defaultConfig { defaultConfig {
minSdk = 33 minSdk = 33