diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 726ce4045c..85d1db6a46 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -102,6 +102,8 @@ platform :android do Dir.glob("#{ENV['PWD']}/**/*.{gradle,gradle.kts,toml}").each do |f| next if f.include?("/build/") || f.include?("/.gradle/") File.readlines(f).each_with_index do |line, idx| + # Comments can name a SNAPSHOT version; only a declaration is a hit. + next if line.lstrip.start_with?("//", "/*", "*", "#") snapshot_hits << "#{f}:#{idx + 1}: #{line.strip}" if line.include?("SNAPSHOT") end end @@ -109,15 +111,18 @@ platform :android do UI.user_error!("SNAPSHOT dependencies found — remove before releasing:\n#{snapshot_hits.join("\n")}") end - build(options) + # 'upload' sends the app bundle, so publish builds the bundle only. + build_aab(options) upload(options) end desc "Upload for pre-launch report" lane :upload do |options| - filename = "#{ENV['PWD']}/wallet/build/outputs/apk/prod/release/wallet-prod-release.apk" + # An app bundle, not the apk: Play rejects an apk this size (both ABIs' + # native libraries), while from a bundle each device downloads only its own ABI. + filename = "#{ENV['PWD']}/wallet/build/outputs/bundle/prodRelease/wallet-prod-release.aab" if !File.exist? "#{filename}" - UI.user_error!("Missing apk. Run 'publish' lane to build and upload") + UI.user_error!("Missing aab. Run 'publish' lane to build and upload") end mapping = "#{ENV['PWD']}/wallet/build/outputs/mapping/prodRelease/mapping.txt" @@ -125,7 +130,9 @@ platform :android do UI.user_error!("Missing mapping.txt. Run 'publish' lane to build and upload") end - supply(apk: filename, mapping: mapping, track: 'internal') + # Upload only the bundle: an apk built in the same run is left in the lane + # context, and supply refuses to send both. + supply(aab: filename, mapping: mapping, track: 'internal', skip_upload_apk: true) end desc "Promote to production track with 0.2 rollout by default" @@ -327,6 +334,9 @@ platform :android do desc "Build apk" lane :build do |options| + # bundle: true builds the app bundle (.aab) instead of the apk (see build_aab). + verb = options[:bundle] ? "bundle" : "assemble" + # Strip PiggyCards test merchants from production release builds. ENV['BUILD_PROD'] = '1' @@ -348,12 +358,12 @@ platform :android do end if is_ci - flavor=options[:flavor].capitalize - type=options[:type].capitalize + flavor = gradle_flavor(options[:flavor].to_s) + type = gradle_type(options[:type].to_s) storepass=options[:storepass] versioncode=options[:versioncode] gradle( - task: "clean assemble#{flavor}#{type}", + task: "clean #{verb}#{flavor}#{type}", properties: { "android.injected.signing.store.file" => "#{ENV['PWD']}/.deploy/keystore.jks", "android.injected.signing.store.password" => storepass, @@ -372,7 +382,7 @@ platform :android do end gradle( - task: "clean assembleProdRelease", + task: "clean #{verb}ProdRelease", properties: { "android.injected.signing.store.file" => "#{ENV['PWD']}/.deploy/dash-wallet.keystore", "android.injected.signing.store.password" => storepass, @@ -384,6 +394,11 @@ platform :android do end end + desc "Build aab" + lane :build_aab do |options| + build(options.merge(bundle: true)) + end + desc "Download explore.db" lane :explore_db do |options| assets_path = "#{ENV['PWD']}/wallet/assets/" diff --git a/wallet/README.md b/wallet/README.md index f661808709..ec86a26d52 100644 --- a/wallet/README.md +++ b/wallet/README.md @@ -197,11 +197,17 @@ The APK is placed here: `wallet/build/outputs/apk/wallet-prod-release.apk` ```sh fastlane build storepass:[keystore password] keypass:[key password] ``` -## Upload existing wallet-prod-release.apk file to the internal test track. +## Build the app bundle for Google Play +Google Play takes the app bundle, not the APK. The bundle is placed here: +`wallet/build/outputs/bundle/prodRelease/wallet-prod-release.aab` +```sh + fastlane build_aab storepass:[keystore password] keypass:[key password] +``` +## Upload existing wallet-prod-release.aab file to the internal test track. ```shell fastlane upload ``` -## Build, followed by Upload +## Build the app bundle, followed by Upload ```shell fastlane publish storepass:[keystore password] keypass:[key password] ```