From 8d1640447f694f22ce1762e5183fee63dda3a8f9 Mon Sep 17 00:00:00 2001 From: Vadim <44135514+vodemn@users.noreply.github.com> Date: Thu, 16 Feb 2023 00:16:39 +0300 Subject: [PATCH] Build signed apk on tag creation (#35) * Create cd.yml * added artifact upload * fixed jobs sequence * moved upload to build job * jobs rename * keystore * Update cd.yml * macos runner * cd_dev * Update build.gradle --- .github/workflows/cd.yml | 42 --------------------------- .github/workflows/cd_dev.yml | 56 ++++++++++++++++++++++++++++++++++++ android/app/build.gradle | 15 ++++++---- 3 files changed, 65 insertions(+), 48 deletions(-) delete mode 100644 .github/workflows/cd.yml create mode 100644 .github/workflows/cd_dev.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index aebef22..0000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,42 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Build app-dev-release.apk - -on: - push: - branches: [ "cd" ] - tags: - - "v*.*.*" - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - uses: subosito/flutter-action@v2 - with: - channel: "stable" - - - name: Check flutter version - run: flutter --version - - - name: Install dependencies - run: flutter pub get - - - name: Generate intl - run: flutter pub run intl_utils:generate - - - name: Analyze project source - run: flutter analyze - - - name: Build Apk - run: flutter build apk --flavor dev --dart-define cameraPreviewAspectRatio=2/3 -t lib/main_dev.dart - - - uses: actions/upload-artifact@v3 - with: - name: m3_lightmeter.apk - path: build/app/outputs/flutter-apk/app-dev-release.apk diff --git a/.github/workflows/cd_dev.yml b/.github/workflows/cd_dev.yml new file mode 100644 index 0000000..55bef58 --- /dev/null +++ b/.github/workflows/cd_dev.yml @@ -0,0 +1,56 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Build app-dev-release.apk + +on: + push: + branches: ["cd"] + tags: + - "v*.*.*" + workflow_dispatch: + +jobs: + build: + runs-on: macos-11 + timeout-minutes: 30 + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v2 + with: + distribution: "zulu" + java-version: "11" + + - name: Restore Android keystore .jsk and .properties files + env: + KEYSTORE: ${{ secrets.KEYSTORE }} + KEYSTORE_PROPERTIES: ${{ secrets.KEYSTORE_PROPERTIES }} + run: | + KEYSTORE_PATH=$RUNNER_TEMP/keystore.jks + echo -n "$KEYSTORE" | base64 --decode --output $KEYSTORE_PATH + cp $KEYSTORE_PATH ./android/app + KEYSTORE_PROPERTIES_PATH=$RUNNER_TEMP/key.properties + echo -n "$KEYSTORE_PROPERTIES" | base64 --decode --output $KEYSTORE_PROPERTIES_PATH + cp $KEYSTORE_PROPERTIES_PATH ./android + + - name: Install Flutter + uses: subosito/flutter-action@v2 + with: + channel: "stable" + + - name: Prepare flutter project + run: | + flutter --version + flutter pub get + flutter pub run intl_utils:generate + + - name: Build Apk + run: flutter build apk --release --flavor dev --dart-define cameraPreviewAspectRatio=2/3 -t lib/main_dev.dart + + - uses: actions/upload-artifact@v3 + with: + name: m3_lightmeter.apk + path: build/app/outputs/flutter-apk/app-dev-release.apk diff --git a/android/app/build.gradle b/android/app/build.gradle index aedfc58..5a98f8f 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -21,6 +21,12 @@ if (flutterVersionName == null) { flutterVersionName = '1.0' } +def keystoreProperties = new Properties() +def keystorePropertiesFile = rootProject.file('key.properties') +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) +} + apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" @@ -50,15 +56,12 @@ android { } signingConfigs { - debug {} - /* release { keyAlias keystoreProperties['keyAlias'] keyPassword keystoreProperties['keyPassword'] storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null storePassword keystoreProperties['storePassword'] } - */ } flavorDimensions "app" @@ -66,12 +69,12 @@ android { dev { applicationId "com.vodemn.lightmeter.dev" dimension "app" - signingConfig signingConfigs.debug + signingConfig signingConfigs.release } prod { applicationId "com.vodemn.lightmeter" dimension "app" - signingConfig signingConfigs.debug + signingConfig signingConfigs.release } } @@ -80,7 +83,7 @@ android { signingConfig signingConfigs.debug } release { - signingConfig signingConfigs.debug + signingConfig signingConfigs.release minifyEnabled true shrinkResources true }