Skip to content

Commit 6f28df7

Browse files
committed
ci: build only unsigned debug apks on PR
1 parent c15e15a commit 6f28df7

2 files changed

Lines changed: 43 additions & 9 deletions

File tree

.github/workflows/ci-android.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
java-version: 21
3636
- uses: gradle/actions/setup-gradle@v4
3737
- name: Decode keystore
38+
if: github.event_name != 'pull_request'
3839
run: echo "${{ secrets.RELEASE_KEYSTORE_FILE }}" | base64 --decode > android/release.keystore
3940
- name: Setup Android SDK
4041
uses: android-actions/setup-android@v3
@@ -43,14 +44,20 @@ jobs:
4344
- name: Install NDK
4445
run: sdkmanager "ndk;30.0.14904198"
4546
- name: Create local.properties
47+
if: github.event_name != 'pull_request'
4648
run: |
4749
cat <<EOF > android/local.properties
4850
RELEASE_STORE_FILE=../release.keystore
4951
RELEASE_STORE_PASSWORD=${{ secrets.RELEASE_STORE_PASSWORD }}
5052
RELEASE_KEY_ALIAS=${{ secrets.RELEASE_KEY_ALIAS }}
5153
RELEASE_KEY_PASSWORD=${{ secrets.RELEASE_KEY_PASSWORD }}
5254
EOF
53-
- name: Build
55+
- name: Build debug APK for PRs
56+
if: github.event_name == 'pull_request'
57+
run: ./gradlew assembleFossDebug
58+
working-directory: android
59+
- name: Build release artifacts
60+
if: github.event_name != 'pull_request'
5461
run: ./gradlew packageReleaseArtifacts
5562
working-directory: android
5663
- name: Get app version
@@ -59,26 +66,37 @@ jobs:
5966
- id: vars
6067
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
6168
- uses: actions/upload-artifact@v4
69+
if: github.event_name != 'pull_request'
6270
with:
6371
name: apk-release
6472
path: release/*release.apk
6573

6674
- uses: actions/upload-artifact@v4
75+
if: github.event_name == 'pull_request'
76+
with:
77+
name: apk-debug
78+
path: android/app/build/outputs/apk/foss/debug/app-foss-debug.apk
79+
80+
- uses: actions/upload-artifact@v4
81+
if: github.event_name != 'pull_request'
6782
with:
6883
name: apk-debug
6984
path: release/*debug.apk
7085

7186
- uses: actions/upload-artifact@v4
87+
if: github.event_name != 'pull_request'
7288
with:
7389
name: root-module-release
7490
path: release/*release.zip
7591

7692
- uses: actions/upload-artifact@v4
93+
if: github.event_name != 'pull_request'
7794
with:
7895
name: root-module-debug
7996
path: release/*debug.zip
8097

8198
- uses: actions/upload-artifact@v4
99+
if: github.event_name != 'pull_request'
82100
with:
83101
name: release-bundle
84102
path: release/*.aab

android/app/build.gradle.kts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,29 @@ plugins {
1010
id("kotlin-parcelize")
1111
}
1212

13+
val localPropsFile = rootProject.file("local.properties")
1314
val props = Properties().apply {
14-
load(rootProject.file("local.properties").inputStream())
15+
if (localPropsFile.exists()) {
16+
load(localPropsFile.inputStream())
17+
}
1518
}
1619

20+
val releaseSigningAvailable = listOf(
21+
"RELEASE_STORE_FILE",
22+
"RELEASE_STORE_PASSWORD",
23+
"RELEASE_KEY_ALIAS",
24+
"RELEASE_KEY_PASSWORD"
25+
).all { props[it]?.toString()?.isNotBlank() == true }
26+
1727
android {
1828
signingConfigs {
19-
create("release") {
20-
storeFile = file(props["RELEASE_STORE_FILE"] as String)
21-
storePassword = props["RELEASE_STORE_PASSWORD"] as String
22-
keyAlias = props["RELEASE_KEY_ALIAS"] as String
23-
keyPassword = props["RELEASE_KEY_PASSWORD"] as String
29+
if (releaseSigningAvailable) {
30+
create("release") {
31+
storeFile = file(props["RELEASE_STORE_FILE"] as String)
32+
storePassword = props["RELEASE_STORE_PASSWORD"] as String
33+
keyAlias = props["RELEASE_KEY_ALIAS"] as String
34+
keyPassword = props["RELEASE_KEY_PASSWORD"] as String
35+
}
2436
}
2537
}
2638
namespace = "me.kavishdevar.librepods"
@@ -45,14 +57,18 @@ android {
4557
}
4658
}
4759
buildConfigField("Boolean", "PLAY_BUILD", "false")
48-
signingConfig = signingConfigs.getByName("release")
60+
if (releaseSigningAvailable) {
61+
signingConfig = signingConfigs.getByName("release")
62+
}
4963
defaultConfig {
5064
minSdk = 33
5165
}
5266
}
5367
debug {
5468
buildConfigField("Boolean", "PLAY_BUILD", "false")
55-
signingConfig = signingConfigs.getByName("release")
69+
if (releaseSigningAvailable) {
70+
signingConfig = signingConfigs.getByName("release")
71+
}
5672
versionNameSuffix = "-debug"
5773
defaultConfig {
5874
minSdk = 33

0 commit comments

Comments
 (0)