From c4db87fc0f6151cead58026decde4bb57db2d2d4 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/release.yaml | 73 +++++++++++++++++++++---------- Gemfile | 3 ++ demoscannerapp/build.gradle | 21 +++++++-- demoscannerapp/proguard-rules.pro | 4 ++ fastlane/Appfile | 1 + fastlane/Fastfile | 59 +++++++++++++++++++++++++ 6 files changed, 136 insertions(+), 25 deletions(-) create mode 100644 Gemfile create mode 100644 fastlane/Appfile create mode 100644 fastlane/Fastfile diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ebe6d8cf..22a54f8d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -21,27 +21,56 @@ jobs: distribution: 'zulu' - name: Gradle cache uses: gradle/actions/setup-gradle@v3 - - name: Gradle build - run: ./gradlew build - env: - GH_DRIVER_REPOSITORY_USERNAME: ${{ secrets.GH_DRIVER_REPOSITORY_USERNAME }} - GH_DRIVER_REPOSITORY_TOKEN: ${{ secrets.GH_DRIVER_REPOSITORY_TOKEN }} - - name: Publish the library to MavenCentral - run: ./gradlew publish + + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.0.2 + bundler-cache: true + +# - name: Gradle build +# run: ./gradlew build +# env: +# GH_DRIVER_REPOSITORY_USERNAME: ${{ secrets.GH_DRIVER_REPOSITORY_USERNAME }} +# GH_DRIVER_REPOSITORY_TOKEN: ${{ secrets.GH_DRIVER_REPOSITORY_TOKEN }} +# - name: Publish the library to MavenCentral +# run: ./gradlew publish +# env: +# OSSRH_LOGIN: ${{ secrets.OSSRH_LOGIN }} +# OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} +# SIGN_KEYID: ${{ secrets.SIGN_KEYID }} +# SIGN_KEY: ${{ secrets.SIGN_KEY }} +# SIGN_PASSWORD: ${{ secrets.SIGN_PASSWORD }} +# LIB_VERSION: ${{ steps.get_version.outputs.VERSION }} +# GH_DRIVER_REPOSITORY_USERNAME: ${{ secrets.GH_DRIVER_REPOSITORY_USERNAME }} +# GH_DRIVER_REPOSITORY_TOKEN: ${{ secrets.GH_DRIVER_REPOSITORY_TOKEN }} +# - name: Rename the AAR file for GitHub release upload +# run: mv enioka_scan/build/outputs/aar/enioka_scan-release.aar enioka_scan/build/outputs/aar/enioka_scan-${{ steps.get_version.outputs.VERSION }}.aar +# - name: Create a GitHub release with the AAR file as an asset +# uses: softprops/action-gh-release@v2 +# with: +# name: ${{ steps.get_version.outputs.VERSION }} +# files: enioka_scan/build/outputs/aar/enioka_scan-${{ steps.get_version.outputs.VERSION }}.aar +# token: ${{ secrets.GITHUB_TOKEN }} + + - 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: Fastlane build and upload + run: bundle exec fastlane internal env: - OSSRH_LOGIN: ${{ secrets.OSSRH_LOGIN }} - OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} - SIGN_KEYID: ${{ secrets.SIGN_KEYID }} - SIGN_KEY: ${{ secrets.SIGN_KEY }} - SIGN_PASSWORD: ${{ secrets.SIGN_PASSWORD }} - LIB_VERSION: ${{ steps.get_version.outputs.VERSION }} - GH_DRIVER_REPOSITORY_USERNAME: ${{ secrets.GH_DRIVER_REPOSITORY_USERNAME }} - GH_DRIVER_REPOSITORY_TOKEN: ${{ secrets.GH_DRIVER_REPOSITORY_TOKEN }} - - name: Rename the AAR file for GitHub release upload - run: mv enioka_scan/build/outputs/aar/enioka_scan-release.aar enioka_scan/build/outputs/aar/enioka_scan-${{ steps.get_version.outputs.VERSION }}.aar - - name: Create a GitHub release with the AAR file as an asset - uses: softprops/action-gh-release@v2 + KEYSTORE_PASSWORD: ${{ secrets.GOOGLE_KEYSTORE_PASSWORD }} + SIGNKEY_PASSWORD: ${{ secrets.GOOGLE_SIGNKEY_PASSWORD }} + KEY_ALIAS: ${{ secrets.GOOGLE_SIGNKEY_ALIAS }} + + - name: Gradle build + run: ./gradlew demoscannerapp:bundleRelease + + - name: Upload aab as artefact + uses: actions/upload-artifact@v2 with: - name: ${{ steps.get_version.outputs.VERSION }} - files: enioka_scan/build/outputs/aar/enioka_scan-${{ steps.get_version.outputs.VERSION }}.aar - token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + name: app-release + path: ${{ github.workspace }}/demoscannerapp/build/outputs/bundle/debug/release/demoscannerapp-debug.aab 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