git.iko.soy/parseable-android
on master help sign in
Configure release signing for Android app builds (#22)
2f6fb81iko
.github/workflows/build-release.yml+11
@@ -22,6 +22,12 @@ jobs:
22 - name: Checkout code
22 - name: Checkout code
23 uses: actions/checkout@v4
23 uses: actions/checkout@v4
24
24
25+ - name: Decode release keystore
26+ if: env.RELEASE_KEYSTORE_BASE64 != ''
27+ env:
28+ RELEASE_KEYSTORE_BASE64: ${{ secrets.RELEASE_KEYSTORE_BASE64 }}
29+ run: echo "$RELEASE_KEYSTORE_BASE64" | base64 -d > app/release.keystore
30+
25 - name: Set up JDK 17
31 - name: Set up JDK 17
26 uses: actions/setup-java@v4
32 uses: actions/setup-java@v4
27 with:
33 with:
@@ -38,6 +44,11 @@ jobs:
38 run: gradle wrapper --gradle-version 8.9
44 run: gradle wrapper --gradle-version 8.9
39
45
40 - name: Build release APK
46 - name: Build release APK
47+ env:
48+ RELEASE_KEYSTORE_FILE: ${{ secrets.RELEASE_KEYSTORE_BASE64 != '' && 'release.keystore' || '' }}
49+ RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }}
50+ RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
51+ RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
41 run: ./gradlew assembleRelease
52 run: ./gradlew assembleRelease
42
53
43 - name: Run unit tests
54 - name: Run unit tests
.github/workflows/ci.yml+22
@@ -18,6 +18,12 @@ jobs:
18 - name: Checkout code
18 - name: Checkout code
19 uses: actions/checkout@v4
19 uses: actions/checkout@v4
20
20
21+ - name: Decode release keystore
22+ if: env.RELEASE_KEYSTORE_BASE64 != ''
23+ env:
24+ RELEASE_KEYSTORE_BASE64: ${{ secrets.RELEASE_KEYSTORE_BASE64 }}
25+ run: echo "$RELEASE_KEYSTORE_BASE64" | base64 -d > app/release.keystore
26+
21 - name: Set up JDK 17
27 - name: Set up JDK 17
22 uses: actions/setup-java@v4
28 uses: actions/setup-java@v4
23 with:
29 with:
@@ -34,6 +40,11 @@ jobs:
34 run: gradle wrapper --gradle-version 8.9
40 run: gradle wrapper --gradle-version 8.9
35
41
36 - name: Build release APK
42 - name: Build release APK
43+ env:
44+ RELEASE_KEYSTORE_FILE: ${{ secrets.RELEASE_KEYSTORE_BASE64 != '' && 'release.keystore' || '' }}
45+ RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }}
46+ RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
47+ RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
37 run: ./gradlew assembleRelease
48 run: ./gradlew assembleRelease
38
49
39 - name: Run unit tests
50 - name: Run unit tests
@@ -73,6 +84,12 @@ jobs:
73 - name: Checkout code
84 - name: Checkout code
74 uses: actions/checkout@v4
85 uses: actions/checkout@v4
75
86
87+ - name: Decode release keystore
88+ if: env.RELEASE_KEYSTORE_BASE64 != ''
89+ env:
90+ RELEASE_KEYSTORE_BASE64: ${{ secrets.RELEASE_KEYSTORE_BASE64 }}
91+ run: echo "$RELEASE_KEYSTORE_BASE64" | base64 -d > app/release.keystore
92+
76 - name: Set version from commit timestamp
93 - name: Set version from commit timestamp
77 run: |
94 run: |
78 VERSION_NAME=$(TZ=UTC git log -1 --format='%cd' --date=format-local:'%Y.%m.%d.%H%M')
95 VERSION_NAME=$(TZ=UTC git log -1 --format='%cd' --date=format-local:'%Y.%m.%d.%H%M')
@@ -94,6 +111,11 @@ jobs:
94 run: gradle wrapper --gradle-version 8.9
111 run: gradle wrapper --gradle-version 8.9
95
112
96 - name: Build release APK
113 - name: Build release APK
114+ env:
115+ RELEASE_KEYSTORE_FILE: ${{ secrets.RELEASE_KEYSTORE_BASE64 != '' && 'release.keystore' || '' }}
116+ RELEASE_KEYSTORE_PASSWORD: ${{ secrets.RELEASE_KEYSTORE_PASSWORD }}
117+ RELEASE_KEY_ALIAS: ${{ secrets.RELEASE_KEY_ALIAS }}
118+ RELEASE_KEY_PASSWORD: ${{ secrets.RELEASE_KEY_PASSWORD }}
97 run: ./gradlew assembleRelease
119 run: ./gradlew assembleRelease
98
120
99 - name: Rename APK with version
121 - name: Rename APK with version
.gitignore+2
@@ -10,3 +10,5 @@
10local.properties
10local.properties
11app/build/
11app/build/
12gradle/wrapper/gradle-wrapper.jar
12gradle/wrapper/gradle-wrapper.jar
13+*.keystore
14+*.jks
app/build.gradle.kts+12−1
@@ -32,11 +32,22 @@ android {
32 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
32 testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
33 }
33 }
34
34
35+ signingConfigs {
36+ if (System.getenv("RELEASE_KEYSTORE_FILE") != null) {
37+ create("release") {
38+ storeFile = file(System.getenv("RELEASE_KEYSTORE_FILE"))
39+ storePassword = System.getenv("RELEASE_KEYSTORE_PASSWORD")
40+ keyAlias = System.getenv("RELEASE_KEY_ALIAS")
41+ keyPassword = System.getenv("RELEASE_KEY_PASSWORD")
42+ }
43+ }
44+ }
45+
35 buildTypes {
46 buildTypes {
36 release {
47 release {
37 isMinifyEnabled = true
48 isMinifyEnabled = true
38 isShrinkResources = true
49 isShrinkResources = true
39− signingConfig = signingConfigs.getByName("debug")
50+ signingConfig = signingConfigs.findByName("release") ?: signingConfigs.getByName("debug")
40 proguardFiles(
51 proguardFiles(
41 getDefaultProguardFile("proguard-android-optimize.txt"),
52 getDefaultProguardFile("proguard-android-optimize.txt"),
42 "proguard-rules.pro"
53 "proguard-rules.pro"