flutter: ci: Add release configs and secrets env
See: https://dev.to/cddelta/signing-flutter-android-apps-for-release-in-github-actions-2892 https://flutterchina.club/android-release/
This commit is contained in:
parent
ba35578931
commit
4312c31446
|
@ -22,6 +22,9 @@ jobs:
|
|||
- uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: '12.x'
|
||||
- run: echo $SIGNING_KEY | base64 -d > src/ui/flutter_app/android/app/key.jks
|
||||
env:
|
||||
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
|
||||
- uses: subosito/flutter-action@v1
|
||||
with:
|
||||
channel: 'dev' # or: 'dev' or 'beta'
|
||||
|
@ -51,6 +54,11 @@ jobs:
|
|||
# Build
|
||||
- name: Build apk
|
||||
run: cd src/ui/flutter_app; flutter build apk
|
||||
env:
|
||||
KEY_STORE_PASSWORD: ${{ secrets.KEY_STORE_PASSWORD }}
|
||||
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
|
||||
ALIAS: ${{ secrets.ALIAS }}
|
||||
KEY_PATH: key.jks
|
||||
|
||||
# Archive
|
||||
- name: Archive production artifacts
|
||||
|
|
|
@ -24,6 +24,17 @@ if (flutterVersionName == null) {
|
|||
apply plugin: 'com.android.application'
|
||||
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
|
||||
|
||||
def keystoreProperties = new Properties()
|
||||
def keystorePropertiesFile = rootProject.file('key.properties')
|
||||
if (keystorePropertiesFile.exists()) {
|
||||
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
|
||||
} else {
|
||||
keystoreProperties.setProperty('storePassword', System.getenv('KEY_STORE_PASSWORD'));
|
||||
keystoreProperties.setProperty('keyPassword', System.getenv('KEY_PASSWORD'));
|
||||
keystoreProperties.setProperty('keyAlias', System.getenv('ALIAS'));
|
||||
keystoreProperties.setProperty('storeFile', System.getenv('KEY_PATH'));
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
|
||||
|
@ -43,11 +54,17 @@ android {
|
|||
}
|
||||
}
|
||||
|
||||
signingConfigs {
|
||||
release {
|
||||
keyAlias keystoreProperties['keyAlias']
|
||||
keyPassword keystoreProperties['keyPassword']
|
||||
storeFile file(keystoreProperties['storeFile'])
|
||||
storePassword keystoreProperties['storePassword']
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
// TODO: Add your own signing config for the release build.
|
||||
// Signing with the debug keys for now, so `flutter run --release` works.
|
||||
signingConfig signingConfigs.debug
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
externalNativeBuild {
|
||||
|
|
Loading…
Reference in New Issue