From 28fe4921f50b1e91edef4746f679053d934e8a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Mon, 24 Apr 2023 16:31:55 +0200 Subject: [PATCH] feat: add test parameter (#1) --- plugins/fastlane-plugin-android_cd/Gemfile | 2 +- .../fastlane/Fastfile | 2 +- .../android_cd/actions/build_and_deploy.rb | 23 +++++++++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/plugins/fastlane-plugin-android_cd/Gemfile b/plugins/fastlane-plugin-android_cd/Gemfile index 89e0953..a11d1f3 100644 --- a/plugins/fastlane-plugin-android_cd/Gemfile +++ b/plugins/fastlane-plugin-android_cd/Gemfile @@ -2,5 +2,5 @@ source('https://rubygems.org') gemspec -plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') +plugins_path = 'fastlane/Pluginfile' eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/plugins/fastlane-plugin-android_cd/fastlane/Fastfile b/plugins/fastlane-plugin-android_cd/fastlane/Fastfile index fdbc775..c2bba1b 100644 --- a/plugins/fastlane-plugin-android_cd/fastlane/Fastfile +++ b/plugins/fastlane-plugin-android_cd/fastlane/Fastfile @@ -1,3 +1,3 @@ lane :test do - android_cd + android_cd(beta_type: "internal") end diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb index d4d76d0..c980207 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb @@ -1,10 +1,24 @@ require 'fastlane/action' require_relative '../helper/android_cd_helper' +def is_set variable + str_variable = variable + str_variable = variable.strip if variable.class.to_s == "String" + variable && !(str_variable.nil? || str_variable.empty?) +end + module Fastlane module Actions class AndroidCdAction < Action def self.run(params) + + # Check parameters + unless is_set(params[:beta_type]) + UI.error("Parameters beta_type cannot be null") + puts "Error on beta type parameter" + end + + UI.message("Building and deploying to Google Play Store in #{params[:beta_type]}") # Decrypt the keys archive and Extract the keys archive Helper::AndroidCdHelper.decrypt_android_keys('.') @@ -27,7 +41,7 @@ module Fastlane # Upload the Android App Bundle to the Play Store Fastlane::Actions.upload_to_play_store( - track: 'internal', + track: params[:beta_type], json_key: './service_account_key.json', aab: '../build/app/outputs/bundle/release/app-release.aab', skip_upload_metadata: true, @@ -35,8 +49,9 @@ module Fastlane skip_upload_screenshots: true, release_status: "draft", version_code: build_number, - package_name: 'com.jaggerlewis.jl_2022' ) + + UI.success('🍺 Successfully build & deploy appbundle to Google Play Store') end def self.description @@ -56,6 +71,10 @@ module Fastlane def self.available_options [ + FastlaneCore::ConfigItem.new(key: :beta_type, + env_name: "ANDROID_CD_TEST_TYPE", + optional: false, + description: "Type of test (production, beta, alpha, internal)"), ] end