Skip to content

Commit 04a5c5d

Browse files
committed
Automatically sign app releases
1 parent 63f0049 commit 04a5c5d

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ jobs:
1717

1818
- name: Build release
1919
run: ./gradlew assembleRelease
20+
env:
21+
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
2022

2123
- uses: actions/upload-artifact@v2
2224
with:
2325
name: app
24-
path: app/build/outputs/apk/release/app-release-unsigned.apk
26+
path: app/build/outputs/apk/release/app-*.apk
2527
if-no-files-found: error
2628

2729
deploy:
@@ -41,6 +43,6 @@ jobs:
4143
with:
4244
prerelease: true
4345
asset_name: pinning-demo.apk
44-
file: ${{ steps.get_apk.outputs.download-path }}/app-release-unsigned.apk
46+
file: ${{ steps.get_apk.outputs.download-path }}/app-release.apk
4547
tag: ${{ github.ref }}
4648
repo_token: ${{ secrets.GITHUB_TOKEN }}

app/build.gradle

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ plugins {
33
id 'kotlin-android'
44
}
55

6+
def keyStorePassword = System.getenv('KEYSTORE_PASSWORD')
7+
def keyAvailable = !!keyStorePassword
8+
69
android {
710
compileSdkVersion 30
811
buildToolsVersion "30.0.2"
@@ -17,9 +20,23 @@ android {
1720
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1821
}
1922

23+
signingConfigs {
24+
release {
25+
storeFile file("./keystore.jks")
26+
storePassword keyStorePassword
27+
keyAlias "signing_key"
28+
keyPassword keyStorePassword
29+
}
30+
}
31+
2032
buildTypes {
2133
release {
2234
minifyEnabled false
35+
if (keyAvailable) {
36+
signingConfig signingConfigs.release
37+
} else {
38+
logger.warn('No signing key available')
39+
}
2340
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
2441
}
2542
}

app/keystore.jks

2.56 KB
Binary file not shown.

0 commit comments

Comments
 (0)