diff --git a/app/build.gradle b/app/build.gradle index 580a1e0d144c..432290f1aa63 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -88,7 +88,30 @@ android { } } } - release + release { + def propertiesPath = "${CI_HOME_DIR}/ddg_android_build.properties" + def propertiesFile = new File(propertiesPath) + if (propertiesFile.exists()) { + def props = new Properties() + props.load(new FileInputStream(propertiesFile)) + storeFile = file("${CI_HOME_DIR}/${props['key.store']}") + storePassword = props['key.store.password'] + keyAlias = props['key.alias'] + keyPassword = props['key.alias.password'] + } + } + upload { + def propertiesPath = "${CI_HOME_DIR}/ddg_android_build_upload.properties" + def propertiesFile = new File(propertiesPath) + if (propertiesFile.exists()) { + def props = new Properties() + props.load(new FileInputStream(propertiesFile)) + storeFile = file("${CI_HOME_DIR}/${props['key.store']}") + storePassword = props['key.store.password'] + keyAlias = props['key.alias'] + keyPassword = props['key.alias.password'] + } + } } buildTypes { debug { @@ -102,11 +125,19 @@ android { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - signingConfig signingConfigs.release manifestPlaceholders = [ appIcon : "@mipmap/ic_launcher_red", appIconRound: "@mipmap/ic_launcher_red_round" ] + + if (project.hasProperty('useUploadSigning')) { + signingConfig = signingConfigs.upload + } else if (isValidSigningConfig(signingConfigs.release)) { + signingConfig = signingConfigs.release + } else { + println "Signing properties not found, release artifacts will not be signed." + signingConfig = null + } } } flavorDimensions "store" @@ -137,20 +168,14 @@ android { unitTests.returnDefaultValues = true animationsDisabled = true } +} - def propertiesPath = "${CI_HOME_DIR}/ddg_android_build.properties" - def propertiesFile = new File(propertiesPath) - if (propertiesFile.exists()) { - def props = new Properties() - props.load(new FileInputStream(propertiesFile)) - android.signingConfigs.release.storeFile = file("${CI_HOME_DIR}/${props['key.store']}") - android.signingConfigs.release.storePassword = props['key.store.password'] - android.signingConfigs.release.keyAlias = props['key.alias'] - android.signingConfigs.release.keyPassword = props['key.alias.password'] - } else { - println "Signing properties not found at ${propertiesPath}, releases will NOT succeed" - android.buildTypes.release.signingConfig = null - } +static def isValidSigningConfig(signingConfig) { + return signingConfig != null && + signingConfig.storeFile?.exists() && + signingConfig.storePassword && + signingConfig.keyAlias && + signingConfig.keyPassword } fulladleModuleConfig { diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 9d7f8c351823..d03633bfbb47 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -52,18 +52,18 @@ platform :android do end - desc "Upload APK to Play Store, in production track with a very small rollout percentage" + desc "Upload AAB to Play Store, in production track with a very small rollout percentage" lane :deploy_playstore do props = property_file_read(file: "app/version/version.properties") version = props["VERSION"] flversion = convert_version(release_number: version) - apkPath = "app/build/outputs/apk/play/release/duckduckgo-#{version}-play-release.apk" + aabPath = "app/build/outputs/bundle/playRelease/duckduckgo-#{version}-play-release.aab" update_fastlane_release_notes(release_number: flversion) upload_to_play_store( - apk: apkPath, + aab: aabPath, track: 'production', rollout: '0.000001', # ie. 0.0001% skip_upload_screenshots: true, @@ -160,10 +160,10 @@ platform :android do props = property_file_read(file: "app/version/version.properties") version = props["VERSION"] - apkPath = "app/build/outputs/apk/play/release/duckduckgo-#{version}-play-release.apk" + aabPath = "app/build/outputs/bundle/playRelease/duckduckgo-#{version}-play-release.aab" upload_to_play_store_internal_app_sharing( - apk: apkPath + aab: aabPath ) end @@ -171,9 +171,9 @@ platform :android do desc "Upload APK to Play Store internal testing track" lane :deploy_dogfood do |options| - UI.message("Apk path: #{options[:apk_path]}") + UI.message("Aab path: #{options[:aab_path]}") upload_to_play_store( - apk: options[:apk_path], + aab: options[:aab_path], track: 'internal', skip_upload_screenshots: true, skip_upload_images: true, @@ -193,6 +193,11 @@ platform :android do UI.message ("Upload new app version to GitHub\nVersion: #{version}\nRelease Notes:\n=====\n#{releaseNotes}\n=====\n") + download_universal_apk_from_google_play( + version_code: convert_version(release_number: version), + destination: apkPath + ) + set_github_release( repository_name: "DuckDuckGo/Android", api_token: token, diff --git a/fastlane/README.md b/fastlane/README.md index e1655856e185..162ce6446d25 100644 --- a/fastlane/README.md +++ b/fastlane/README.md @@ -21,7 +21,7 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do [bundle exec] fastlane android deploy_playstore ``` -Upload APK to Play Store, in production track with a very small rollout percentage +Upload AAB to Play Store, in production track with a very small rollout percentage ### android update_release_notes_playstore