Skip to content

Commit 3848924

Browse files
authored
ci: add signing the APK to the building workflow (#44)
* ci: add signing the APK to the workflow * ci: add decoding keystore secrets on CI
1 parent b7ef5a5 commit 3848924

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

.github/workflows/artifact_building.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ jobs:
1515
- name: Decode secrets
1616
env:
1717
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
18+
KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_PROPERTIES }}
19+
KEYSTORE: ${{ secrets.KEYSTORE }}
1820
run: |
1921
echo "$GOOGLE_SERVICES" | base64 --decode > ./app/google-services.json
22+
echo "$KEYSTORE_PROPERTIES" | base64 --decode > ./keystore.properties
23+
echo "$KEYSTORE" | base64 --decode > ./keystore.jks
2024
2125
- name: Setup JDK
2226
uses: actions/setup-java@v4
@@ -45,5 +49,5 @@ jobs:
4549
uses: actions/upload-artifact@v4
4650
with:
4751
name: app-release.apk
48-
path: app/build/outputs/apk/release/app-release-unsigned.apk
52+
path: app/build/outputs/apk/release/app-release.apk
4953

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,12 @@ jobs:
3131
- name: Decode secrets
3232
env:
3333
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }}
34+
KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_PROPERTIES }}
35+
KEYSTORE: ${{ secrets.KEYSTORE }}
3436
run: |
3537
echo "$GOOGLE_SERVICES" | base64 --decode > ./app/google-services.json
38+
echo "$KEYSTORE_PROPERTIES" | base64 --decode > ./keystore.properties
39+
echo "$KEYSTORE" | base64 --decode > ./keystore.jks
3640
3741
# Kernel-based Virtual Machine (KVM) is an open source virtualization technology built into Linux. Enabling it allows the Android emulator to run faster.
3842
- name: Enable KVM group perms

app/build.gradle.kts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import org.apache.commons.compress.harmony.pack200.PackingUtils.config
2+
import java.io.FileInputStream
3+
import java.util.Properties
4+
15
plugins {
26
alias(libs.plugins.androidApplication)
37
alias(libs.plugins.jetbrainsKotlinAndroid)
@@ -7,6 +11,16 @@ plugins {
711
id("com.google.gms.google-services")
812
}
913

14+
// Create a variable called keystorePropertiesFile, and initialize it to your
15+
// keystore.properties file, in the rootProject folder.
16+
val keystorePropertiesFile = rootProject.file("keystore.properties")
17+
18+
// Initialize a new Properties() object called keystoreProperties.
19+
val keystoreProperties = Properties()
20+
21+
// Load your keystore.properties file into the keystoreProperties object.
22+
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
23+
1024
android {
1125
namespace = "ch.hikemate.app"
1226
compileSdk = 34
@@ -24,13 +38,23 @@ android {
2438
}
2539
}
2640

41+
signingConfigs {
42+
create("release") {
43+
keyAlias = keystoreProperties["keyAlias"] as String
44+
keyPassword = keystoreProperties["keyPassword"] as String
45+
storeFile = file(keystoreProperties["storeFile"] as String)
46+
storePassword = keystoreProperties["storePassword"] as String
47+
}
48+
}
49+
2750
buildTypes {
2851
release {
2952
isMinifyEnabled = false
3053
proguardFiles(
3154
getDefaultProguardFile("proguard-android-optimize.txt"),
3255
"proguard-rules.pro"
3356
)
57+
signingConfig = signingConfigs.getByName("release")
3458
}
3559

3660
debug {

0 commit comments

Comments
 (0)