From 0b6938c7f21cf59394085e241e978081c0569ba5 Mon Sep 17 00:00:00 2001 From: VincentKobz Date: Wed, 3 Jul 2024 17:30:14 +0200 Subject: [PATCH] feat: Add internal and production track to release into PlayStore on CD --- .github/workflows/playstore.yaml | 52 +++++++++++++++++++++++++++ Gemfile | 3 ++ demoscannerapp/build.gradle | 21 +++++++++-- demoscannerapp/proguard-rules.pro | 4 +++ fastlane/Appfile | 1 + fastlane/Fastfile | 59 +++++++++++++++++++++++++++++++ 6 files changed, 137 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/playstore.yaml create mode 100644 Gemfile create mode 100644 fastlane/Appfile create mode 100644 fastlane/Fastfile diff --git a/.github/workflows/playstore.yaml b/.github/workflows/playstore.yaml new file mode 100644 index 00000000..3a78bf93 --- /dev/null +++ b/.github/workflows/playstore.yaml @@ -0,0 +1,52 @@ +name: PlayStore release + +on: + push: + branches: + - 129-playstore-cd-deployment + workflow_dispatch: + inputs: + deployment_type: + type: choice + description: "Deployment type" + options: + - internal + - production + default: internal + required: true + +jobs: + playstore: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: "3.0.2" + bundler-cache: true + + - name: Restore json key + run: echo "${{ secrets.GOOGLE_API_PUB_JSON_BASE64 }}" | base64 --decode > ${{ github.workspace }}/service-account.json + + - name: Restore keystore + run: echo "${{ secrets.GOOGLE_KEYSTORE_BASE64 }}" | base64 --decode > ${{ github.workspace }}/demoscannerapp/debug.keystore + + - name: Set up environment + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'zulu' + + - name: Gradle cache + uses: gradle/actions/setup-gradle@v3 + + - name: Fastlane build and upload + run: bundle exec fastlane $DEPLOYMENT_TYPE + env: + DEPLOYMENT_TYPE: internal + KEYSTORE_PASSWORD: ${{ secrets.GOOGLE_KEYSTORE_PASSWORD }} + SIGNKEY_PASSWORD: ${{ secrets.GOOGLE_SIGNKEY_PASSWORD }} + KEY_ALIAS: ${{ secrets.GOOGLE_SIGNKEY_ALIAS }} diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..7a118b49 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gem "fastlane" diff --git a/demoscannerapp/build.gradle b/demoscannerapp/build.gradle index 7a81d975..3221aa41 100644 --- a/demoscannerapp/build.gradle +++ b/demoscannerapp/build.gradle @@ -5,15 +5,29 @@ android { defaultConfig { applicationId "com.enioka.scanner.demoscannerapp" minSdkVersion 19 - targetSdkVersion 28 - versionCode 1 + targetSdkVersion 33 + versionCode 4 versionName "1.0" vectorDrawables.useSupportLibrary = true testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - + } + signingConfigs { + debug { + storeFile file("debug.keystore") + storePassword System.getenv("KEYSTORE_PASSWORD") + keyAlias System.getenv("KEY_ALIAS") + keyPassword System.getenv("SIGNKEY_PASSWORD") + } + release { + storeFile file("debug.keystore") + storePassword System.getenv("KEYSTORE_PASSWORD") + keyAlias System.getenv("KEY_ALIAS") + keyPassword System.getenv("SIGNKEY_PASSWORD") + } } buildTypes { release { + signingConfig signingConfigs.release minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' @@ -21,6 +35,7 @@ android { applicationIdSuffix ".release" } debug { + signingConfig signingConfigs.debug debuggable true applicationIdSuffix ".debug" } diff --git a/demoscannerapp/proguard-rules.pro b/demoscannerapp/proguard-rules.pro index eef921c1..94e2735b 100644 --- a/demoscannerapp/proguard-rules.pro +++ b/demoscannerapp/proguard-rules.pro @@ -23,3 +23,7 @@ # If you keep the line number information, uncomment this to # hide the original source file name. #-renamesourcefileattribute SourceFile + +-keep class net.sourceforge.zbar.** { +*; +} diff --git a/fastlane/Appfile b/fastlane/Appfile new file mode 100644 index 00000000..c98263f0 --- /dev/null +++ b/fastlane/Appfile @@ -0,0 +1 @@ +json_key_file("service-account.json") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one diff --git a/fastlane/Fastfile b/fastlane/Fastfile new file mode 100644 index 00000000..6005a7cf --- /dev/null +++ b/fastlane/Fastfile @@ -0,0 +1,59 @@ +# This file contains the fastlane.tools configuration +# You can find the documentation at https://docs.fastlane.tools +# +# For a list of all available actions, check out +# +# https://docs.fastlane.tools/actions +# +# For a list of all available plugins, check out +# +# https://docs.fastlane.tools/plugins/available-plugins +# + +# Uncomment the line if you want fastlane to automatically update itself +# update_fastlane + +default_platform(:android) + +platform :android do + + lane :default do + internal + end + + # LANE 1 + desc "Publish a new version to the Google Play (INTERNAL)" + lane :internal do + + # Generate AAB file + gradle( + task: "demoscannerapp:bundle", + build_type: "Release" + ) + + # Upload the AAB to play store (internal track) + upload_to_play_store( + package_name: "com.enioka.scanner.demoscannerapp.release", + track: 'internal', + release_status: "draft" + ) + end + + # LANE 2 + desc "Publish a new version to the Google Play (PRODUCTION)" + lane :release do + + # Generate AAB file + gradle( + task: "demoscannerapp:bundle", + build_type: "Release" + ) + + # Upload the AAB to play store (internal track) + upload_to_play_store( + package_name: "com.enioka.scanner.demoscannerapp.release", + track: 'production', + release_status: "draft" + ) + end +end