From f58d40c7545dd356d96ee44d90e002e0e7e7909e Mon Sep 17 00:00:00 2001 From: Virginia Vila <106952548+v-vila@users.noreply.github.com> Date: Fri, 8 Mar 2024 12:10:31 +0100 Subject: [PATCH] feat: android match action --- fastlane/.env.default | 2 -- .../common/actions/android_match_action.rb | 23 ++++++++----------- 2 files changed, 10 insertions(+), 15 deletions(-) delete mode 100644 fastlane/.env.default diff --git a/fastlane/.env.default b/fastlane/.env.default deleted file mode 100644 index ea88cb8..0000000 --- a/fastlane/.env.default +++ /dev/null @@ -1,2 +0,0 @@ -ANDROID_MATCH_DEBUG_KEYSTORE=debug.keystore -ANDROID_MATCH_RELEASE_KEYSTORE=release.jks \ No newline at end of file diff --git a/lib/fastlane/plugin/common/actions/android_match_action.rb b/lib/fastlane/plugin/common/actions/android_match_action.rb index c845e7a..41eb6a7 100644 --- a/lib/fastlane/plugin/common/actions/android_match_action.rb +++ b/lib/fastlane/plugin/common/actions/android_match_action.rb @@ -1,28 +1,25 @@ -require 'fastlane/action' -require 'fastlane_core' - module Fastlane module Actions class AndroidMatchAction < Action def self.run(params) - keystore = params[:keystore] type = params[:type] + keystore = params[:keystore] if type == 'debug' - keystore = ENV.fetch('ANDROID_MATCH_DEBUG_KEYSTORE', nil) + keystore ||= ENV['ANDROID_MATCH_DEBUG_KEYSTORE'] elsif type == 'release' - keystore = ENV.fetch('ANDROID_MATCH_RELEASE_KEYSTORE', nil) - elsif type - raise "Invalid type #{type}. Valid values: debug|release." + keystore ||= ENV['ANDROID_MATCH_RELEASE_KEYSTORE'] + else + raise "Invalid type '#{type}'. Valid values: debug|release." end - raise "Missing keystore #{keystore}." unless keystore + raise "Missing keystore for type '#{type}'." unless keystore - raise 'The keystore already exists. If you want to redownload it, please run with the --force flag.' if !params[:force] && File.exist?(keystore) + raise "The keystore '#{keystore}' already exists. If you want to redownload it, please run with the --force flag." unless params[:force] || !File.exist?(keystore) temp_dir = Dir.mktmpdir - git_url = ENV.fetch('ANDROID_MATCH_URL', nil) - git_branch = ENV.fetch('ANDROID_MATCH_BRANCH', nil) + git_url = ENV['ANDROID_MATCH_URL'] + git_branch = ENV['ANDROID_MATCH_BRANCH'] sh("git clone --branch #{git_branch} #{git_url} #{temp_dir}") FileUtils.cp("#{temp_dir}/#{keystore}", '.') @@ -59,4 +56,4 @@ def self.is_supported?(platform) end end end -end +end \ No newline at end of file