diff --git a/plugins/fastlane-plugin-android_cd/README.md b/plugins/fastlane-plugin-android_cd/README.md index bc0cac8..9e5600f 100644 --- a/plugins/fastlane-plugin-android_cd/README.md +++ b/plugins/fastlane-plugin-android_cd/README.md @@ -10,7 +10,7 @@ This project is a [_fastlane_](https://github.com/fastlane/fastlane) plugin. To fastlane add_plugin android_cd ``` -## About android_cd +## About build_and_deploy Google Play Store deployment plugin for Fastlane, simplifying the build and deployment process to internal, beta, alpha, and production channels, and promoting builds for testing. @@ -31,6 +31,7 @@ rake ``` To automatically fix many of the styling issues, use + ``` rubocop -a ``` diff --git a/plugins/fastlane-plugin-android_cd/fastlane/Fastfile b/plugins/fastlane-plugin-android_cd/fastlane/Fastfile index c2bba1b..79918ea 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(beta_type: "internal") + build_and_deploy(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_action.rb similarity index 90% rename from plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy.rb rename to plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb index e4abd70..316ab0e 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_action.rb @@ -3,7 +3,7 @@ require_relative '../helper/android_cd_helper' module Fastlane module Actions - class AndroidCdAction < Action + class BuildAndDeployAction < Action def self.run(params) # Check parameters unless Helper::AndroidCdHelper.is_set(params[:beta_type]) @@ -11,7 +11,7 @@ module Fastlane puts("Error on beta type parameter") end - UI.message("Building and deploying to Google Play Store in #{params[:beta_type]}") + 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('.') @@ -59,7 +59,7 @@ module Fastlane end def self.details - "The Fastlane Google Play Store deployment plugin streamlines the build and deployment process to internal, beta, alpha, and production channels, simplifying the process of distributing builds for testing. With its advanced promotion functionality, it also enables easy promotion of builds to higher beta testing phases, helping you get your app to market faster." + "The Fastlane Google Play Store deployment action streamlines the build and deployment process to internal, beta, alpha, and production channels, simplifying the process of distributing builds for testing. With its advanced promotion functionality, it also enables easy promotion of builds to higher beta testing phases, helping you get your app to market faster." end def self.available_options @@ -72,6 +72,7 @@ module Fastlane end def self.is_supported?(platform) + # Restrict the use of the plugin to Android. [:android].include?(platform) end end diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/promote_action.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/promote_action.rb new file mode 100644 index 0000000..6e7656b --- /dev/null +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/promote_action.rb @@ -0,0 +1,74 @@ +require 'fastlane/action' +require_relative '../helper/android_cd_helper' + +module Fastlane + module Actions + class BuildAndDeployAction < Action + def self.run(params) + # Check from parameters + unless Helper::AndroidCdHelper.is_set(params[:from]) + UI.error("❌ Parameters from cannot be null") + puts("Error on beta type parameter") + end + + unless Helper::AndroidCdHelper.is_set(params[:destination]) + UI.error("❌ Parameters destination cannot be null") + puts("Error on beta type parameter") + end + + UI.message("⌛️ Promoting to Google Play Store from #{params[:from]} to #{params[:destination]}..") + + # Decrypt the keys archive and Extract the keys archive + Helper::AndroidCdHelper.decrypt_android_keys('.') + + # Upload the Android App Bundle to the Play Store + Fastlane::Actions.upload_to_play_store( + track: params[:beta_type], + json_key: './service_account_key.json', + skip_upload_apk: true, + skip_upload_aab: true, + skip_upload_metadata: true, + skip_upload_changelogs: true, + skip_upload_images: true, + skip_upload_screenshots: true + ) + + UI.success('🍺 Successfully promote appbundle to Google Play Store') + end + + def self.description + "The Fastlane Google Play Store deployment action streamlines the build and deployment process to internal, beta, alpha, and production channels, simplifying the process of distributing builds for testing. With its advanced promotion functionality, it also enables easy promotion of builds to higher beta testing phases, helping you get your app to market faster." + end + + def self.authors + ["SAS Wyatt Studio"] + end + + def self.return_value + end + + def self.details + "The Fastlane Google Play Store deployment action to promote to internal, beta, alpha, and production channels, simplifying the process of distributing builds for testing." + end + + def self.available_options + [ + FastlaneCore::ConfigItem.new(key: :from, + env_name: "ANDROID_CD_BETA_FROM", + optional: false, + description: "Actual deployed test (production, beta, alpha, internal)"), + + FastlaneCore::ConfigItem.new(key: :destination, + env_name: "ANDROID_CD_BETA_DESTINATION", + optional: false, + description: "Destination of test (production, beta, alpha, internal)") + ] + end + + def self.is_supported?(platform) + # Restrict the use of the plugin to Android. + [:android].include?(platform) + end + end + end +end diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb index 3aa310d..adb8c05 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/helper/android_cd_helper.rb @@ -21,6 +21,7 @@ module Fastlane end end + # Check if a parameter is set or not def self.is_set(variable) str_variable = variable str_variable = variable.strip if variable.class.to_s == "String" diff --git a/plugins/fastlane-plugin-android_cd/spec/android_cd_action_spec.rb b/plugins/fastlane-plugin-android_cd/spec/build_and_deploy_action_spec.rb similarity index 59% rename from plugins/fastlane-plugin-android_cd/spec/android_cd_action_spec.rb rename to plugins/fastlane-plugin-android_cd/spec/build_and_deploy_action_spec.rb index dac01eb..6545fa0 100644 --- a/plugins/fastlane-plugin-android_cd/spec/android_cd_action_spec.rb +++ b/plugins/fastlane-plugin-android_cd/spec/build_and_deploy_action_spec.rb @@ -1,9 +1,9 @@ -describe Fastlane::Actions::AndroidCdAction do +describe Fastlane::Actions::BuildAndDeployAction do describe '#run' do it 'prints a message' do expect(Fastlane::UI).to receive(:message).with("The android_cd plugin is working!") - Fastlane::Actions::AndroidCdAction.run(nil) + Fastlane::Actions::BuildAndDeployAction.run(nil) end end end