Skip to content

Commit ac655e3

Browse files
authored
chore: start signing builds in github actions (#2405)
1 parent f38f5d1 commit ac655e3

File tree

5 files changed

+32
-8
lines changed

5 files changed

+32
-8
lines changed

.github/workflows/push-event.yml

+19-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,28 @@ jobs:
1919
- name: Download repository
2020
uses: actions/checkout@v3
2121

22-
- name: Setup Java
23-
uses: actions/setup-java@v3
22+
- uses: actions/cache@v3
2423
with:
25-
distribution: 'adopt'
26-
java-version: '17'
24+
path: |
25+
~/.gradle/caches
26+
~/.gradle/wrapper
27+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
28+
restore-keys: |
29+
${{ runner.os }}-gradle-
30+
31+
- name: Prepare Build Keys
32+
if: ${{ github.event_name != 'pull_request' && github.repository == 'fossasia/pslab-android' }}
33+
env:
34+
ENCRYPTED_F10B5E0E5262_IV: ${{ secrets.ENCRYPTED_F10B5E0E5262_IV }}
35+
ENCRYPTED_F10B5E0E5262_KEY: ${{ secrets.ENCRYPTED_F10B5E0E5262_KEY }}
36+
run: |
37+
bash scripts/prep-key.sh
2738
2839
- name: Build with Gradle
40+
env:
41+
STORE_PASS: ${{ secrets.STORE_PASS }}
42+
ALIAS: ${{ secrets.ALIAS }}
43+
KEY_PASS: ${{ secrets.KEY_PASS }}
2944
run: |
3045
bash ./gradlew build --stacktrace
3146
bash ./gradlew bundle --stacktrace

app/build.gradle.kts

+5-4
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

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.jks
2+
fastlane.json
3+
secrets.tar

scripts/prep-key.sh

+5
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)