Skip to content

Commit 6f88b19

Browse files
committed
chore: start signing builds in github actions
1 parent 3465dab commit 6f88b19

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

.github/workflows/push-event.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,34 @@ jobs:
1919
- name: Download repository
2020
uses: actions/checkout@v3
2121

22+
- uses: actions/cache@v3
23+
with:
24+
path: |
25+
~/.gradle/caches
26+
~/.gradle/wrapper
27+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
28+
restore-keys: |
29+
${{ runner.os }}-gradle-
30+
2231
- name: Setup Java
2332
uses: actions/setup-java@v3
2433
with:
2534
distribution: 'adopt'
2635
java-version: '17'
2736

37+
- name: Prepare Build Keys
38+
if: ${{ github.event_name != 'pull_request' && github.repository == 'fossasia/pslab-android' }}
39+
env:
40+
ENCRYPTED_F10B5E0E5262_IV: ${{ secrets.ENCRYPTED_F10B5E0E5262_IV }}
41+
ENCRYPTED_F10B5E0E5262_KEY: ${{ secrets.ENCRYPTED_F10B5E0E5262_KEY }}
42+
run: |
43+
bash scripts/prep-key.sh
44+
2845
- name: Build with Gradle
46+
env:
47+
STORE_PASS: ${{ secrets.STORE_PASS }}
48+
ALIAS: ${{ secrets.ALIAS }}
49+
KEY_PASS: ${{ secrets.KEY_PASS }}
2950
run: |
3051
bash ./gradlew build --stacktrace
3152
bash ./gradlew bundle --stacktrace

app/build.gradle.kts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ plugins {
44

55
apply(plugin = "realm-android")
66

7-
val keystoreExists = System.getenv("KEYSTORE_FILE") != null
7+
val KEYSTORE_FILE = rootProject.file("scripts/key.jks")
8+
val GITHUB_BUILD = System.getenv("GITHUB_ACTIONS") == "true" && KEYSTORE_FILE.exists()
89

910
android {
1011
namespace = "io.pslab"
@@ -19,9 +20,9 @@ android {
1920
}
2021

2122
signingConfigs {
22-
if (keystoreExists) {
23+
if (GITHUB_BUILD) {
2324
register("release") {
24-
storeFile = file(System.getenv("KEYSTORE_FILE"))
25+
storeFile = KEYSTORE_FILE
2526
storePassword = System.getenv("STORE_PASS")
2627
keyAlias = System.getenv("ALIAS")
2728
keyPassword = System.getenv("KEY_PASS")
@@ -41,7 +42,7 @@ android {
4142
"proguard-rules.pro"
4243
)
4344
resValue("string", "version", "${defaultConfig.versionName}")
44-
signingConfig = if (keystoreExists) signingConfigs.getByName("release") else null
45+
signingConfig = if (GITHUB_BUILD) signingConfigs.getByName("release") else null
4546
}
4647
}
4748
lint {

scripts/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.jks
2+
fastlane.json
3+
secrets.tar

scripts/prep-key.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
set -e
3+
4+
openssl aes-256-cbc -K $ENCRYPTED_F10B5E0E5262_KEY -iv $ENCRYPTED_F10B5E0E5262_IV -in ./scripts/secrets.tar.enc -out ./scripts/secrets.tar -d
5+
tar xvf ./scripts/secrets.tar -C scripts/

scripts/secrets.tar.enc

6.02 KB
Binary file not shown.

0 commit comments

Comments
 (0)