From 18a72b6100e9496d0d912bd0745ebe30882b0e79 Mon Sep 17 00:00:00 2001 From: Robert Virkus Date: Wed, 27 Dec 2023 11:08:51 +0100 Subject: [PATCH] chore: work on Android CI --- .github/workflows/flutter.yml | 16 ++++- android/app/build.gradle | 121 +++++++++++++--------------------- 2 files changed, 59 insertions(+), 78 deletions(-) diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml index b7fcfea..fa760ee 100644 --- a/.github/workflows/flutter.yml +++ b/.github/workflows/flutter.yml @@ -10,6 +10,18 @@ jobs: name: Build Android runs-on: ubuntu-latest steps: + - name: Decode Keystore and Create key.properties + env: + ENCODED_STRING: ${{ secrets.PLAY_UPLOAD_KEYSTORE }} + PROPERTIES_PATH: ${{ github.workspace }}/android/key.properties + run: | + TMP_KEYSTORE_FILE_PATH="${{ github.workspace }}/android/keystore + mkdir "${TMP_KEYSTORE_FILE_PATH}" + echo $ENCODED_STRING | base64 -di > "${TMP_KEYSTORE_FILE_PATH}"/google_play_upload.jks + echo keyPassword=\${{ secrets.PLAY_UPLOAD_KEY_PASSWORD }} > ${{env.PROPERTIES_PATH}} + echo storePassword=\${{ secrets.PLAY_UPLOAD_STORE_PASSWORD }} >> ${{env.PROPERTIES_PATH}} + echo keyAlias=\${{ secrets.PLAY_KEY_ALIAS }} >> ${{env.PROPERTIES_PATH}} + echo storeFile=\${TMP_KEYSTORE_FILE_PATH}/google_play_upload.jks >> ${{env.PROPERTIES_PATH}} - uses: actions/checkout@v3 - uses: actions/setup-java@v2 with: @@ -21,8 +33,8 @@ jobs: - run: flutter --version - run: flutter pub get #- run: flutter test - # build debug version for now until automated signing is in place: - - run: flutter build apk --debug + - run: flutter build apk --release + apple: name: Build iOS runs-on: macos-13 # required for xcode 15, macos-latest does not yet support it, compare https://github.com/maxim-lobanov/setup-xcode/issues/73 diff --git a/android/app/build.gradle b/android/app/build.gradle index 66eac96..647dde1 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,99 +26,68 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" def keystorePropertiesFile = rootProject.file('key.properties') -if (keystorePropertiesFile.exists()) { - def keystoreProperties = new Properties() - keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) - - android { - defaultConfig { - multiDexEnabled true - } - - compileOptions { - // Flag to enable support for the new language APIs - coreLibraryDesugaringEnabled true - // Sets Java compatibility to Java 8 - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } +def keystoreProperties = new Properties() - compileSdkVersion rootProject.ext.compileSdkVersion - - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } - - lintOptions { - disable 'InvalidPackage' - } - - defaultConfig { - applicationId "de.enough.enough_mail_app" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName - } - - signingConfigs { - release { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile file(keystoreProperties['storeFile']) - storePassword keystoreProperties['storePassword'] - } - } +if (keystorePropertiesFile.exists()) { + keystorePropertiesFile.withReader('UTF-8') { reader -> + keystoreProperties.load(reader) + } +} - buildTypes { - release { - signingConfig signingConfigs.release - } - } +android { + defaultConfig { + multiDexEnabled true } -} else { - System.out.println("warning: android/key.properties not found, now using debug key.") - android { - defaultConfig { - multiDexEnabled true - } + compileOptions { + // Flag to enable support for the new language APIs + coreLibraryDesugaringEnabled true + // Sets Java compatibility to Java 8 + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } - compileOptions { - // Flag to enable support for the new language APIs - coreLibraryDesugaringEnabled true - // Sets Java compatibility to Java 8 - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } + compileSdkVersion rootProject.ext.compileSdkVersion - compileSdkVersion rootProject.ext.compileSdkVersion + sourceSets { + main.java.srcDirs += 'src/main/kotlin' + } - sourceSets { - main.java.srcDirs += 'src/main/kotlin' - } + lintOptions { + disable 'InvalidPackage' + } - lintOptions { - disable 'InvalidPackage' - } + defaultConfig { + applicationId "de.enough.enough_mail_app" + minSdkVersion rootProject.ext.minSdkVersion + targetSdkVersion rootProject.ext.targetSdkVersion + versionCode flutterVersionCode.toInteger() + versionName flutterVersionName + } - defaultConfig { - applicationId "de.enough.enough_mail_app" - minSdkVersion rootProject.ext.minSdkVersion - targetSdkVersion rootProject.ext.targetSdkVersion - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName + signingConfigs { + release { + keyAlias keystoreProperties['keyAlias'] + keyPassword keystoreProperties['keyPassword'] + storeFile file(keystoreProperties['storeFile']) + storePassword keystoreProperties['storePassword'] } + } - buildTypes { - release { - signingConfig signingConfigs.debug + buildTypes { + release { + if (keystorePropertiesFile.exists()) { + signingConfig signingConfigs.release + } else { + System.err.println("WARNING: android/key.properties not found, now using debug key.") + signingConfig signingConfigs.debug } } } } + flutter { source '../..' }