diff --git a/.github/workflows/build-android-prod.yml b/.github/workflows/build-android-prod.yml index 167850b0f..37f0f080b 100644 --- a/.github/workflows/build-android-prod.yml +++ b/.github/workflows/build-android-prod.yml @@ -98,13 +98,6 @@ jobs: env: BUILD_TOOLS_VERSION: "33.0.0" - - name: Upload AAB artifact to GitHub - uses: actions/upload-artifact@v3 - with: - name: Signed Android AAB ${{ inputs.brand }} - path: | - android/app/build/outputs/bundle/prodRelease/*.aab - - name: Upload App to Google Play uses: r0adkll/upload-google-play@v1 with: @@ -112,3 +105,50 @@ jobs: packageName: ${{ inputs.brand != 'cozy' && format('io.cozy.flagship.mobile.{0}', inputs.brand) || 'io.cozy.flagship.mobile' }} releaseFiles: android/app/build/outputs/bundle/prodRelease/*.aab track: internal + + - name: Download BundleTool + run: | + curl -L https://github.com/google/bundletool/releases/download/1.8.0/bundletool-all-1.8.0.jar -o bundletool.jar + + - name: Decode signing key + run: echo "${{ secrets[format('{0}_ANDROID_SIGNING_KEY', inputs.brand)] }}" | base64 --decode > signingKey.jks + env: + BUILD_TOOLS_VERSION: "33.0.0" + + - name: Generate APK Set from AAB + run: | + java -jar bundletool.jar build-apks \ + --bundle=android/app/build/outputs/bundle/prodRelease/app-prod-release.aab \ + --output=app-prod-release.apks \ + --mode=universal \ + --ks=signingKey.jks \ + --ks-pass=pass:${{ secrets[format('{0}_ANDROID_KEY_STORE_PASSWORD', inputs.brand)] }} \ + --ks-key-alias=${{ secrets[format('{0}_ANDROID_ALIAS', inputs.brand)] }} \ + --key-pass=pass:${{ secrets[format('{0}_ANDROID_KEY_PASSWORD', inputs.brand)] }} + + - name: Rename .apks file to .zip + run: mv app-prod-release.apks app-prod-release.zip + + - name: Unzip the universal APK from the .zip file + run: unzip app-prod-release.zip -d ./extracted-apks + + - name: Rename and move Universal APK + run: | + APK_PATH=$(find ./extracted-apks -name '*.apk') + mv "$APK_PATH" "./extracted-apks/cozy_flagship_universal.apk" + + - name: Extract Version Info and Define Artifact Name + run: | + GRADLE_PATH="./android/app/build.gradle" + VERSION_CODE=$(awk '/versionCode/ {print}' $GRADLE_PATH | sed 's/[^0-9*]//g' | bc) + VERSION_NAME=$(grep versionName $GRADLE_PATH | awk -F '"' '{print $2}') + ARTIFACT_NAME="App-$VERSION_NAME-$VERSION_CODE-${{ github.event.inputs.brand }}" + echo "ARTIFACT_NAME=$ARTIFACT_NAME" >> $GITHUB_ENV + echo "::set-output name=artifact_name::$ARTIFACT_NAME" + id: artifact_info + + - name: Upload APK artifact to GitHub + uses: actions/upload-artifact@v3 + with: + name: ${{ steps.artifact_info.outputs.artifact_name }} + path: ./extracted-apks/cozy_flagship_universal.apk diff --git a/android/app/build.gradle b/android/app/build.gradle index 560f3be91..22aa2c6c1 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -127,11 +127,6 @@ def jscFlavor = 'org.webkit:android-jsc:+' */ def enableHermes = project.ext.react.get("enableHermes", false); -/** - * Architectures to build native code for in debug. - */ -def nativeArchitectures = project.getProperties().get("reactNativeDebugArchitectures") - android { ndkVersion rootProject.ext.ndkVersion @@ -143,7 +138,7 @@ android { namespace = "io.cozy.flagship.mobile" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 101260 + versionCode 101260 * 10000 // Legacy version number patch, needed for Play Store version increment versionName "1.1.26" multiDexEnabled true resValue "string", "build_config_package", "io.cozy.flagship.mobile" @@ -151,10 +146,8 @@ android { } splits { abi { - reset() - enable enableSeparateBuildPerCPUArchitecture - universalApk false // If true, also generate a universal APK - include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" + enable false + universalApk true } } signingConfigs { @@ -168,11 +161,6 @@ android { buildTypes { debug { signingConfig signingConfigs.debug - if (nativeArchitectures) { - ndk { - abiFilters nativeArchitectures.split(',') - } - } } release { // Caution! In production, you need to generate your own keystore file. @@ -184,22 +172,6 @@ android { } } - // applicationVariants are e.g. debug, release - applicationVariants.all { variant -> - variant.outputs.each { output -> - // For each separate APK per architecture, set a unique version code as described here: - // https://developer.android.com/studio/build/configure-apk-splits.html - // Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc. - def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] - def abi = output.getFilter(OutputFile.ABI) - if (abi != null) { // null for the universal-debug, universal-release variants - output.versionCodeOverride = - defaultConfig.versionCode * 1000 + versionCodes.get(abi) - } - - } - } - // to load dev/google-services.json and prod/google-services.json flavorDimensions "version" productFlavors {