Skip to content

Commit 86cd560

Browse files
committed
chore: Add automatic release build in CI
Signed-off-by: Marcel Klehr <[email protected]>
1 parent cfcbbce commit 86cd560

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

.github/workflows/build.yml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,57 @@ jobs:
7474
key: build-context-${{ github.run_id }}
7575
path: ./
7676

77+
- name: Create JKS file from secrets
78+
env:
79+
ANDROID_CERT: ${{ secrets.ANDROID_CERT }}
80+
ANDROID_PRIV_KEY: ${{ secrets.ANDROID_PRIV_KEY }}
81+
ANDROID_JKS_PASSWORD: ${{ secrets.ANDROID_JKS_PASSWORD }}
82+
run: |
83+
# Create temporary directory
84+
mkdir -p keystore
85+
86+
# Combine certificate and private key into PEM format
87+
echo "$ANDROID_CERT" > keystore/cert.pem
88+
echo "$ANDROID_PRIV_KEY" > keystore/key.pem
89+
90+
# Combine certificate and private key into PKCS12 format
91+
# Use a temporary password since we need to specify one
92+
openssl pkcs12 -export -in keystore/cert.pem -inkey keystore/key.pem \
93+
-out keystore/app.p12 -name key0 -password pass:temp-password
94+
95+
# Convert PKCS12 to JKS format
96+
keytool -importkeystore -srckeystore keystore/app.p12 -srcstoretype PKCS12 \
97+
-destkeystore keystore/app.jks -deststoretype JKS -srcstorepass temp-password \
98+
-deststorepass "$ANDROID_JKS_PASSWORD" -destkeypass "$ANDROID_JKS_PASSWORD"
99+
100+
# Clean up temporary files
101+
rm keystore/cert.pem keystore/key.pem keystore/app.p12
102+
103+
# Make sure the keystore file is not readable by others
104+
chmod 600 keystore/app.jks
105+
106+
- name: Create gradle.properties file
107+
run: |
108+
cat >> android/gradle.properties << EOF
109+
FLOCCUS_STORE_FILE=../keystore/app.jks
110+
FLOCCUS_STORE_PASSWORD=${{ secrets.KEYSTORE_PASSWORD }}
111+
FLOCCUS_KEY_ALIAS=key0
112+
FLOCCUS_KEY_PASSWORD=${{ secrets.KEY_PASSWORD }}
113+
EOF
114+
77115
- name: Build android
78116
run: |
79117
npx cap sync
80118
cd android
81119
chmod +x gradlew
82-
./gradlew assemble
120+
./gradlew assembleRelease
121+
122+
- name: Upload build artifact
123+
uses: actions/upload-artifact@v4
124+
with:
125+
name: "floccus-build-${{ github.sha }}.apk"
126+
path: app/build/outputs/apk/release/app-release.apk
127+
retention-days: 7
83128

84129
ios:
85130
needs: js

android/app/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,17 @@ android {
1919
"appAuthRedirectScheme": "org.handmadeideas.floccus"
2020
]
2121
}
22+
signingConfigs {
23+
release {
24+
storeFile file(FLOCCUS_STORE_FILE)
25+
storePassword FLOCCUS_STORE_PASSWORD
26+
keyAlias FLOCCUS_KEY_ALIAS
27+
keyPassword FLOCCUS_KEY_PASSWORD
28+
}
29+
}
2230
buildTypes {
2331
release {
32+
signingConfig signingConfigs.release
2433
minifyEnabled false
2534
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2635
}

0 commit comments

Comments
 (0)