From 82fd090a79510e131ebdcc4245cb476f6a5a998a Mon Sep 17 00:00:00 2001 From: Marcos Rodriguez Velez Date: Sun, 3 Nov 2024 18:47:58 -0400 Subject: [PATCH] OPS: Fix APK sign path --- fastlane/Fastfile | 49 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 5e8ef9418..fa6264290 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -20,10 +20,10 @@ platform :android do desc "Prepare the keystore file" lane :prepare_keystore do - keystore_file_hex = ENV['KEYSTORE_FILE_HEX'] - UI.user_error!("KEYSTORE_FILE_HEX environment variable is missing") if keystore_file_hex.nil? - Dir.chdir(project_root) do + keystore_file_hex = ENV['KEYSTORE_FILE_HEX'] + UI.user_error!("KEYSTORE_FILE_HEX environment variable is missing") if keystore_file_hex.nil? + UI.message("Creating keystore from HEX...") File.write("bluewallet-release-key.keystore.hex", keystore_file_hex) @@ -60,34 +60,33 @@ platform :android do signed_apk_name = branch_name != 'master' ? "BlueWallet-#{version_name}-#{build_number}-#{branch_name}.apk" : "BlueWallet-#{version_name}-#{build_number}.apk" # Build APK - Dir.chdir("android") do - UI.message("Building APK...") - gradle(task: "assembleRelease", project_dir: "android") - UI.message("APK build completed.") + UI.message("Building APK...") + sh("cd android && ./gradlew assembleRelease") + UI.message("APK build completed.") - # Define paths - unsigned_apk_path = "app/build/outputs/apk/release/app-release-unsigned.apk" - signed_apk_path = "app/build/outputs/apk/release/#{signed_apk_name}" + # Define paths + unsigned_apk_path = "android/app/build/outputs/apk/release/app-release-unsigned.apk" + signed_apk_path = "android/app/build/outputs/apk/release/#{signed_apk_name}" - # Rename APK - if File.exist?(unsigned_apk_path) - UI.message("Renaming APK to #{signed_apk_name}...") - FileUtils.mv(unsigned_apk_path, signed_apk_path) - ENV['APK_OUTPUT_PATH'] = File.expand_path(signed_apk_path) - else - UI.error("Unsigned APK not found at path: #{unsigned_apk_path}") - next - end - - # Sign APK - UI.message("Signing APK with apksigner...") - apksigner_path = "#{ENV['ANDROID_HOME']}/build-tools/34.0.0/apksigner" - sh("#{apksigner_path} sign --ks ./bluewallet-release-key.keystore --ks-pass=pass:#{ENV['KEYSTORE_PASSWORD']} #{signed_apk_path}") - UI.message("APK signed successfully: #{signed_apk_path}") + # Rename APK + if File.exist?(unsigned_apk_path) + UI.message("Renaming APK to #{signed_apk_name}...") + FileUtils.mv(unsigned_apk_path, signed_apk_path) + ENV['APK_OUTPUT_PATH'] = File.expand_path(signed_apk_path) + else + UI.error("Unsigned APK not found at path: #{unsigned_apk_path}") + next end + + # Sign APK + UI.message("Signing APK with apksigner...") + apksigner_path = "#{ENV['ANDROID_HOME']}/build-tools/34.0.0/apksigner" + sh("#{apksigner_path} sign --ks #{project_root}/bluewallet-release-key.keystore --ks-pass=pass:#{ENV['KEYSTORE_PASSWORD']} #{signed_apk_path}") + UI.message("APK signed successfully: #{signed_apk_path}") end end + desc "Upload APK to BrowserStack and post result as PR comment" lane :upload_to_browserstack_and_comment do Dir.chdir(project_root) do