From c36c30ff75fe462870e33eb507eae65f5ea3e9e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Wed, 26 Apr 2023 11:00:26 +0200 Subject: [PATCH 1/2] refactor: rename action --- plugins/fastlane-plugin-android_cd/README.md | 3 ++- plugins/fastlane-plugin-android_cd/fastlane/Fastfile | 2 +- .../{build_and_deploy.rb => build_and_deploy_action.rb} | 2 +- .../lib/fastlane/plugin/android_cd/actions/promote_action.rb | 0 ...roid_cd_action_spec.rb => build_and_deploy_action_spec.rb} | 4 ++-- 5 files changed, 6 insertions(+), 5 deletions(-) rename plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/{build_and_deploy.rb => build_and_deploy_action.rb} (98%) create mode 100644 plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/promote_action.rb rename plugins/fastlane-plugin-android_cd/spec/{android_cd_action_spec.rb => build_and_deploy_action_spec.rb} (59%) 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 98% 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..5236d35 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]) 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..e69de29 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 -- 2.47.2 From bd46322ab34820442a479e35968bb16421a032c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malo=20L=C3=A9on?= Date: Wed, 26 Apr 2023 11:27:58 +0200 Subject: [PATCH 2/2] feat: add promote feature (#1) --- .../actions/build_and_deploy_action.rb | 5 +- .../android_cd/actions/promote_action.rb | 74 +++++++++++++++++++ .../android_cd/helper/android_cd_helper.rb | 1 + 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb index 5236d35..316ab0e 100644 --- a/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb +++ b/plugins/fastlane-plugin-android_cd/lib/fastlane/plugin/android_cd/actions/build_and_deploy_action.rb @@ -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 index e69de29..6e7656b 100644 --- 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 @@ -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" -- 2.47.2