Allow building signed app using GitLab CI

This commit is contained in:
Kirill Kamakin
2021-11-20 11:12:07 +03:00
parent bec22a68ed
commit 25ac2c3851
2 changed files with 37 additions and 15 deletions

View File

@@ -10,8 +10,8 @@ cache:
- .gradle - .gradle
stages: stages:
- check
- build - build
- test
assembleDebug: assembleDebug:
interruptible: true interruptible: true
@@ -21,15 +21,32 @@ assembleDebug:
- ./gradlew assembleDebug - ./gradlew assembleDebug
artifacts: artifacts:
paths: paths:
- app/build/outputs/ - app/build/outputs/apk/debug/*.apk
debugTests: checkApp:
interruptible: true interruptible: true
stage: test stage: check
needs: [ "assembleDebug" ] needs: [ ]
script: script:
- ./gradlew testDebug - ./gradlew check
artifacts: artifacts:
when: always when: always
reports: reports:
junit: ./**/build/test-results/**/TEST-*.xml junit: ./**/build/test-results/**/TEST-*.xml
assembleRelease:
interruptible: true
stage: build
needs: [ ]
script:
- echo "$MEALIE_KEY_STORE" | base64 -d > app/mealie-release-key.jks
- echo "keystorePath=mealie-release-key.jks" > keystore.properties
- echo "keystorePassword=$MEALIE_KEY_STORE_PASSWORD" >> keystore.properties
- echo "keyAlias=$MEALIE_KEY_ALIAS" >> keystore.properties
- echo "keyPassword=$MEALIE_KEY_PASSWORD" >> keystore.properties
- ./gradlew assembleRelease
artifacts:
paths:
- app/build/outputs/apk/release/*.apk
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'

View File

@@ -7,10 +7,6 @@ plugins {
id 'org.jetbrains.kotlin.plugin.serialization' id 'org.jetbrains.kotlin.plugin.serialization'
} }
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android { android {
compileSdk 31 compileSdk 31
@@ -24,10 +20,19 @@ android {
signingConfigs { signingConfigs {
release { release {
keyAlias keystoreProperties['keyAlias'] file("../keystore.properties").with { keystorePropertiesFile ->
keyPassword keystoreProperties['keyPassword'] if (keystorePropertiesFile.canRead()) {
storeFile file(keystoreProperties['storeFile']) def keystoreProperties = new Properties()
storePassword keystoreProperties['storePassword'] keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
} else {
println 'Unable to read keystore.properties'
}
}
} }
} }