From 0a111bcdafb441a36131fabf165276b157c84e46 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Fri, 7 May 2021 11:32:19 -0500 Subject: [PATCH 01/57] abstract section name when getting release version for android --- Gemfile.lock | 4 +-- .../helper/android/android_version_helper.rb | 33 +++++++++++++------ .../plugin/wpmreleasetoolkit/version.rb | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0db26ab55..8ef24adc2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - fastlane-plugin-wpmreleasetoolkit (0.18.1) + fastlane-plugin-wpmreleasetoolkit (0.18.2) activesupport (~> 5) bigdecimal (~> 1.4) chroma (= 0.2.0) @@ -19,7 +19,7 @@ GEM remote: https://rubygems.org/ specs: CFPropertyList (3.0.3) - activesupport (5.2.5) + activesupport (5.2.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index a3919772f..2b7f2fde5 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -30,8 +30,8 @@ module VersionHelper # - If this version is a hotfix (more than 2 parts and 3rd part is non-zero), returns the "X.Y.Z" formatted string # - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number # - def self.get_public_version - version = get_release_version + def self.get_public_version(section) + version = get_version_from_section(section) vp = get_version_parts(version[VERSION_NAME]) return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" unless is_hotfix?(version) @@ -46,7 +46,15 @@ def self.get_public_version # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # def self.get_release_version - section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {' + section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'wordpress {' + return get_version_from_section(section) + end + + # Extract the version name and code from a given secion of the `$PROJECT_NAME/build.gradle file` + # + # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively + # + def self.get_version_from_section(section) gradle_path = self.gradle_path name = get_version_name_from_gradle_file(gradle_path, section) code = get_version_build_from_gradle_file(gradle_path, section) @@ -60,12 +68,7 @@ def self.get_release_version # def self.get_alpha_version return nil if ENV['HAS_ALPHA_VERSION'].nil? - - section = 'defaultConfig' - gradle_path = self.gradle_path - name = get_version_name_from_gradle_file(gradle_path, section) - code = get_version_build_from_gradle_file(gradle_path, section) - return { VERSION_NAME => name, VERSION_CODE => code } + return get_version_from_section('defaultConfig') end # Determines if a version name corresponds to an alpha version (starts with `"alpha-"`` prefix) @@ -258,7 +261,17 @@ def self.is_hotfix?(version) # def self.bump_version_release # Bump release - current_version = get_release_version() + section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'wordpress {' + return bump_version_for_section(section) + end + + # Prints the current and next version names for a given section to stdout, then returns the next version + # + # @return [String] The next version name to use after bumping the currently used version. + # + def self.bump_version_for_section(section) + # Bump release + current_version = get_version_from_section(section) UI.message("Current version: #{current_version[VERSION_NAME]}") new_version = calc_next_release_base_version(current_version) UI.message("New version: #{new_version[VERSION_NAME]}") diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/version.rb index 6bd4a8590..ee9c3a6c0 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/version.rb @@ -1,5 +1,5 @@ module Fastlane module Wpmreleasetoolkit - VERSION = '0.18.1' + VERSION = '0.18.2' end end From 5fcededee9db929dedccda55bbdc77b47fb18363 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Fri, 7 May 2021 11:47:42 -0500 Subject: [PATCH 02/57] add param to get release version to allow for handling jetpack --- .../actions/android/android_get_release_version.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index 10a9b266a..e698da9e5 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -3,6 +3,10 @@ module Actions class AndroidGetReleaseVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' + app = params[:app] + if(!app.nil?) { + return Fastlane::Helper::Android::VersionHelper.get_version_from_section(params[:app]) + } Fastlane::Helper::Android::VersionHelper.get_release_version() end From 15dd87e8433cf819003902bdb9f8e0a5823d1903 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Fri, 7 May 2021 11:51:09 -0500 Subject: [PATCH 03/57] update syntax errror --- .../actions/android/android_get_release_version.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index e698da9e5..3cd4dd755 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -4,9 +4,8 @@ class AndroidGetReleaseVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' app = params[:app] - if(!app.nil?) { - return Fastlane::Helper::Android::VersionHelper.get_version_from_section(params[:app]) - } + return Fastlane::Helper::Android::VersionHelper.get_version_from_section(params[:app]) unless app.nil? + Fastlane::Helper::Android::VersionHelper.get_release_version() end From c88cc2488a0e96ccfb727649c1266c80681e9e27 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Fri, 7 May 2021 11:52:56 -0500 Subject: [PATCH 04/57] include app in available options --- .../actions/android/android_get_release_version.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index 3cd4dd755..8eae39578 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -23,6 +23,13 @@ def self.details def self.available_options # Define all options your action supports. + [ + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one + ] end def self.output From 1cc4399d720f05238075bf2bf0d7aed51c441e55 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 12 May 2021 14:00:24 -0500 Subject: [PATCH 05/57] update action callsites to now include an app name --- .../android/android_bump_version_beta.rb | 26 ++- .../android_bump_version_final_release.rb | 24 ++- .../android/android_bump_version_hotfix.rb | 17 +- .../android/android_bump_version_release.rb | 26 ++- .../android/android_codefreeze_prechecks.rb | 13 +- .../android_completecodefreeze_prechecks.rb | 11 +- .../android_current_branch_is_hotfix.rb | 10 +- .../android/android_finalize_prechecks.rb | 7 +- .../android/android_get_alpha_version.rb | 9 +- .../android/android_get_app_version.rb | 9 +- .../android/android_get_release_version.rb | 5 +- .../actions/android/android_tag_build.rb | 11 +- .../helper/android/android_version_helper.rb | 158 ++++-------------- 13 files changed, 158 insertions(+), 168 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index cfc01cc5b..f2de9353b 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -8,11 +8,13 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' Fastlane::Helper::GitHelper.ensure_on_branch!('release') + @flavor = params[:app] + create_config() show_config() UI.message 'Updating build.gradle...' - Fastlane::Helper::Android::VersionHelper.update_versions(@new_version_beta, @new_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(params[:app], @new_version_beta, @new_version_alpha) UI.message 'Done!' Fastlane::Helper::Android::GitHelper.commit_version_bump() @@ -31,6 +33,14 @@ def self.details end def self.available_options + # Define all options your action supports. + [ + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one + ] end def self.output @@ -49,9 +59,9 @@ def self.is_supported?(platform) private - def self.create_config - @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version() - @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version() + def self.create_config(flavor) + @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@flavor) + @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@flavor) @new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_beta_version(@current_version, @current_version_alpha) @new_version_alpha = ENV['HAS_ALPHA_VERSION'].nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(@new_version_beta, @current_version_alpha) end @@ -59,10 +69,10 @@ def self.create_config def self.show_config vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE - UI.message("Current version: #{@current_version[vname]}(#{@current_version[vcode]})") - UI.message("Current alpha version: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? - UI.message("New beta version: #{@new_version_beta[vname]}(#{@new_version_beta[vcode]})") - UI.message("New alpha version: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? + UI.message("Current version[#{@flavor}]: #{@current_version[vname]}(#{@current_version[vcode]})") + UI.message("Current alpha version[#{@flavor}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? + UI.message("New beta version[#{@flavor}]: #{@new_version_beta[vname]}(#{@new_version_beta[vcode]})") + UI.message("New alpha version[#{@flavor}]: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? end end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index bf40104b7..86ff25011 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -8,11 +8,12 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' Fastlane::Helper::GitHelper.ensure_on_branch!('release') + @flavor = params[:app] create_config() show_config() UI.message 'Updating gradle.properties...' - Fastlane::Helper::Android::VersionHelper.update_versions(@final_version, @current_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(@flavor, @final_version, @current_version_alpha) UI.message 'Done!' Fastlane::Helper::Android::GitHelper.commit_version_bump() @@ -30,6 +31,17 @@ def self.details 'Bumps the version of the app for a new beta' end + def self.available_options + # Define all options your action supports. + [ + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one + ] + end + def self.authors ['loremattei'] end @@ -41,17 +53,17 @@ def self.is_supported?(platform) private def self.create_config - @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version() - @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version() + @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@flavor) + @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@flavor) @final_version = Fastlane::Helper::Android::VersionHelper.calc_final_release_version(@current_version, @current_version_alpha) end def self.show_config vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE - UI.message("Current version: #{@current_version[vname]}(#{@current_version[vcode]})") - UI.message("Current alpha version: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? - UI.message("New release version: #{@final_version[vname]}(#{@final_version[vcode]})") + UI.message("Current version[#{{@flavor}}]: #{@current_version[vname]}(#{@current_version[vcode]})") + UI.message("Current alpha version[#{{@flavor}}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? + UI.message("New release version[#{{@flavor}}]: #{@final_version[vname]}(#{@final_version[vcode]})") end end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 0557cb695..7041d9152 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -6,11 +6,13 @@ def self.run(params) require_relative '../../helper/android/android_git_helper.rb' Fastlane::Helper::GitHelper.create_branch("release/#{params[:version_name]}", from: params[:previous_version_name]) + + @flavor = params[:app] create_config(params[:previous_version_name], params[:version_name], params[:version_code]) show_config() UI.message 'Updating build.gradle...' - Fastlane::Helper::Android::VersionHelper.update_versions(@new_version, @current_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(@flavor, @new_version, @current_version_alpha) UI.message 'Done!' Fastlane::Helper::Android::GitHelper.commit_version_bump() @@ -46,6 +48,11 @@ def self.available_options env_name: 'FL_ANDROID_BUMP_VERSION_HOTFIX_PREVIOUS_VERSION', description: 'The version to branch from', is_string: true), # the default value if the user didn't provide one + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one ] end @@ -60,16 +67,16 @@ def self.is_supported?(platform) private def self.create_config(previous_version, new_version_name, new_version_code) - @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version() - @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version() + @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@flavor) + @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@flavor) @new_version = Fastlane::Helper::Android::VersionHelper.calc_next_hotfix_version(new_version_name, new_version_code) @new_short_version = new_version_name @new_release_branch = "release/#{@new_short_version}" end def self.show_config - UI.message("Current version: #{@current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{@current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") - UI.message("New hotfix version: #{@new_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{@new_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") + UI.message("Current version[#{@flavor}]: #{@current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{@current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") + UI.message("New hotfix version[#{@flavor}]: #{@new_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{@new_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") UI.message("Release branch: #{@new_release_branch}") end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index 0b6bc3781..e25b1cb04 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -12,6 +12,8 @@ def self.run(params) # Create new configuration @new_short_version = Fastlane::Helper::Android::VersionHelper.bump_version_release() + @flavor = params[:app] + create_config() show_config() @@ -21,7 +23,7 @@ def self.run(params) UI.message 'Done!' UI.message 'Updating versions...' - Fastlane::Helper::Android::VersionHelper.update_versions(@new_version_beta, @new_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(params[:app], @new_version_beta, @new_version_alpha) Fastlane::Helper::Android::GitHelper.commit_version_bump() UI.message 'Done.' end @@ -39,6 +41,14 @@ def self.details end def self.available_options + # Define all options your action supports. + [ + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one + ] end def self.output @@ -58,8 +68,8 @@ def self.is_supported?(platform) private def self.create_config - @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version() - @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version() + @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@flavor) + @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@flavor) @new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_release_version(@current_version, @current_version_alpha) @new_version_alpha = ENV['HAS_ALPHA_VERSION'].nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(@new_version_beta, @current_version_alpha) @new_release_branch = "release/#{@new_short_version}" @@ -68,11 +78,11 @@ def self.create_config def self.show_config vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE - UI.message("Current version: #{@current_version[vname]}(#{@current_version[vcode]})") - UI.message("Current alpha version: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? - UI.message("New beta version: #{@new_version_beta[vname]}(#{@new_version_beta[vcode]})") - UI.message("New alpha version: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? - UI.message("New version: #{@new_short_version}") + UI.message("Current version[#{@flavor}]: #{@current_version[vname]}(#{@current_version[vcode]})") + UI.message("Current alpha version[#{@flavor}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? + UI.message("New beta version[#{@flavor}]: #{@new_version_beta[vname]}(#{@new_version_beta[vcode]})") + UI.message("New alpha version[#{@flavor}]: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? + UI.message("New version[#{@flavor}]: #{@new_short_version}") UI.message("Release branch: #{@new_release_branch}") end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb index 36e324dba..badda5059 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb @@ -14,15 +14,17 @@ def self.run(params) # Checkout develop and update Fastlane::Helper::GitHelper.checkout_and_pull('develop') + app = param[:app] + # Create versions - current_version = Fastlane::Helper::Android::VersionHelper.get_release_version - current_alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version + current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + current_alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) next_version = Fastlane::Helper::Android::VersionHelper.calc_next_release_version(current_version, current_alpha_version) next_alpha_version = ENV['HAS_ALPHA_VERSION'].nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(next_version, current_alpha_version) # Ask user confirmation unless params[:skip_confirm] - confirm_message = "Building a new release branch starting from develop.\nCurrent version is #{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" + confirm_message = "[#{params[:app]}]Building a new release branch starting from develop.\nCurrent version is #{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" confirm_message += ENV['HAS_ALPHA_VERSION'].nil? ? "No alpha version configured.\n" : "Current Alpha version is #{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" confirm_message += "After codefreeze the new version will be: #{next_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{next_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" confirm_message += ENV['HAS_ALPHA_VERSION'].nil? ? '' : "After codefreeze the new Alpha will be: #{next_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{next_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" @@ -57,6 +59,11 @@ def self.available_options description: 'Skips confirmation before codefreeze', is_string: false, # true: verifies the input is a string, false: every kind of value default_value: false), # the default value if the user didn't provide one + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb index 2b54f09ea..119092ad7 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb @@ -9,8 +9,10 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') - version = Fastlane::Helper::Android::VersionHelper.get_public_version - message = "Completing code freeze for: #{version}\n" + app = params[:app] + + version = Fastlane::Helper::Android::VersionHelper.get_public_version(app) + message = "Completing code freeze for: [#{app}]#{version}\n" unless params[:skip_confirm] UI.user_error!('Aborted by user request') unless UI.confirm("#{message}Do you want to continue?") else @@ -42,6 +44,11 @@ def self.available_options description: 'Skips confirmation', is_string: false, # true: verifies the input is a string, false: every kind of value default_value: false), # the default value if the user didn't provide one + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb index 8c1142e1d..30abab1a0 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb @@ -7,7 +7,7 @@ module SharedValues class AndroidCurrentBranchIsHotfixAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - Fastlane::Helper::Android::VersionHelper.is_hotfix?(Fastlane::Helper::Android::VersionHelper.get_release_version) + Fastlane::Helper::Android::VersionHelper.is_hotfix?(Fastlane::Helper::Android::VersionHelper.get_release_version(params[:app])) end ##################################################### @@ -23,6 +23,14 @@ def self.details end def self.available_options + # Define all options your action supports. + [ + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one + ] end def self.output diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb index ea3eb90a6..b895749c4 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb @@ -13,7 +13,7 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') - version = Fastlane::Helper::Android::VersionHelper.get_public_version + version = Fastlane::Helper::Android::VersionHelper.get_public_version(params[:app]) message = "Finalizing release: #{version}\n" if !params[:skip_confirm] UI.user_error!('Aborted by user request') unless UI.confirm("#{message}Do you want to continue?") @@ -49,6 +49,11 @@ def self.available_options description: 'Skips confirmation', is_string: false, # true: verifies the input is a string, false: every kind of value default_value: false), # the default value if the user didn't provide one + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb index 025a2b74b..6155e8129 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb @@ -3,7 +3,7 @@ module Actions class AndroidGetAlphaVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - Fastlane::Helper::Android::VersionHelper.get_alpha_version() + Fastlane::Helper::Android::VersionHelper.get_alpha_version(params[:app]) end ##################################################### @@ -20,6 +20,13 @@ def self.details def self.available_options # Define all options your action supports. + [ + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one + ] end def self.output diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb index 15c5a10b9..fea52026d 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb @@ -3,7 +3,7 @@ module Actions class AndroidGetAppVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - Fastlane::Helper::Android::VersionHelper.get_public_version + Fastlane::Helper::Android::VersionHelper.get_public_version(params[:app]) end ##################################################### @@ -20,6 +20,13 @@ def self.details def self.available_options # Define all options your action supports. + [ + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one + ] end def self.output diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index 8eae39578..461722d10 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -3,10 +3,7 @@ module Actions class AndroidGetReleaseVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - app = params[:app] - return Fastlane::Helper::Android::VersionHelper.get_version_from_section(params[:app]) unless app.nil? - - Fastlane::Helper::Android::VersionHelper.get_release_version() + Fastlane::Helper::Android::VersionHelper.get_release_version(params[:app]) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb index 8b4b7a493..8f18c44d2 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb @@ -5,8 +5,10 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' require_relative '../../helper/android/android_git_helper.rb' - release_ver = Fastlane::Helper::Android::VersionHelper.get_release_version() - alpha_ver = Fastlane::Helper::Android::VersionHelper.get_alpha_version() unless ENV['HAS_ALPHA_VERSION'].nil? + app = params[:app] + + release_ver = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + alpha_ver = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) unless ENV['HAS_ALPHA_VERSION'].nil? Fastlane::Helper::GitHelper.create_tag(release_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]) Fastlane::Helper::GitHelper.create_tag(alpha_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]) unless ENV['HAS_ALPHA_VERSION'].nil? || (params[:tag_alpha] == false) end @@ -30,6 +32,11 @@ def self.available_options description: 'True to skip tagging the alpha version', is_string: false, default_value: true), + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 2b7f2fde5..823d1cec5 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -30,45 +30,56 @@ module VersionHelper # - If this version is a hotfix (more than 2 parts and 3rd part is non-zero), returns the "X.Y.Z" formatted string # - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number # - def self.get_public_version(section) - version = get_version_from_section(section) + def self.get_public_version(app) + version = get_version_from_flavor(app) vp = get_version_parts(version[VERSION_NAME]) return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" unless is_hotfix?(version) "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}" end - # Extract the version name and code from the `vanilla` flavor of the `$PROJECT_NAME/build.gradle file` + # Extract the version name and code from the flavor of the `$PROJECT_NAME/build.gradle file` # or for the defaultConfig if `HAS_ALPHA_VERSION` is not defined. # # @env HAS_ALPHA_VERSION If set (with any value), indicates that the project uses `vanilla` flavor. # # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # - def self.get_release_version - section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'wordpress {' - return get_version_from_section(section) + def self.get_release_version(app) + return get_version_from_flavor(app, ENV['HAS_ALPHA_VERSION'].nil?) end # Extract the version name and code from a given secion of the `$PROJECT_NAME/build.gradle file` # # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # - def self.get_version_from_section(section) - gradle_path = self.gradle_path - name = get_version_name_from_gradle_file(gradle_path, section) - code = get_version_build_from_gradle_file(gradle_path, section) + def self.get_version_from_flavor(flavor, isAlpha) + version_name_key = "#{flavor}.#{isAlpha ? 'alpha.':''}versionName" + version_code_key = "#{flavor}.#{isAlpha ? 'alpha.':''}versionCode" + name = get_value_from_properties_file(version_name_key) + code = get_value_from_properties_file(version_code_key) return { VERSION_NAME => name, VERSION_CODE => code } end + def self.get_value_from_properties_file(key) + properties_file_path = File.join(ENV['PROJECT_ROOT_FOLDER'] || '.', 'version.properties') + + return nil unless File.exists?(properties_file_path) + + File.open(properties_file_path, 'r') do | f | + text = f.read + text.match(/#{key}=(\S*)/m)&.captures&.first + end + end + # Extract the version name and code from the `defaultConfig` of the `$PROJECT_NAME/build.gradle` file # # @return [Hash] A hash with 2 keys `"name"` and `"code"` containing the extracted version name and code, respectively, # or `nil` if `$HAS_ALPHA_VERSION` is not defined. # - def self.get_alpha_version + def self.get_alpha_version(app) return nil if ENV['HAS_ALPHA_VERSION'].nil? - return get_version_from_section('defaultConfig') + return get_version_from_flavor(app, true) end # Determines if a version name corresponds to an alpha version (starts with `"alpha-"`` prefix) @@ -259,19 +270,18 @@ def self.is_hotfix?(version) # # @return [String] The next release version name to use after bumping the currently used release version. # - def self.bump_version_release + def self.bump_version_release(app) # Bump release - section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'wordpress {' - return bump_version_for_section(section) + return bump_version_for_app(app, ENV['HAS_ALPHA_VERSION'].nil?) end # Prints the current and next version names for a given section to stdout, then returns the next version # # @return [String] The next version name to use after bumping the currently used version. # - def self.bump_version_for_section(section) + def self.bump_version_for_app(app, isAlpha) # Bump release - current_version = get_version_from_section(section) + current_version = get_version_from_flavor(app, isAlpha) UI.message("Current version: #{current_version[VERSION_NAME]}") new_version = calc_next_release_base_version(current_version) UI.message("New version: #{new_version[VERSION_NAME]}") @@ -286,9 +296,11 @@ def self.bump_version_for_section(section) # @param [Hash] new_version_alpha The version hash for the alpha (defaultConfig), containing values for keys "name" and "code" # @env HAS_ALPHA_VERSION If set (with any value), indicates that the project uses `vanilla` flavor. # - def self.update_versions(new_version_beta, new_version_alpha) - self.update_version(new_version_beta, ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {') - self.update_version(new_version_alpha, 'defaultConfig') unless new_version_alpha.nil? + def self.update_versions(app, new_version_beta, new_version_alpha) + new_version_beta_key = "#{app}.versionName" + new_version_alpha_key = "#{app}.alpha.versionName" + Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_beta_key}", "-Pvalue=#{new_version_beta}") + Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_alpha_key}", "-Pvalue=#{new_version_alpha}") unless new_version_alpha.nil? end # Compute the name of the previous hotfix version. @@ -350,56 +362,6 @@ def self.get_version_parts(version) return parts end - # Extract the versionName from a build.gradle file - # - # @param [String] file_path The path to the `.gradle` file - # @param [String] section The name of the section we expect the keyword to be in, e.g. "defaultConfig" or "vanilla" - # - # @return [String] The value of the versionName attribute as found in the build.gradle file and for this section. - # - def self.get_version_name_from_gradle_file(file_path, section) - res = get_keyword_from_gradle_file(file_path, section, 'versionName') - res = res.tr('\"', '') unless res.nil? - return res - end - - # Extract the versionCode rom a build.gradle file - # - # @param [String] file_path The path to the `.gradle` file - # @param [String] section The name of the section we expect the keyword to be in, e.g. "defaultConfig" or "vanilla" - # - # @return [String] The value of the versionCode attribute as found in the build.gradle file and for this section. - # - def self.get_version_build_from_gradle_file(file_path, section) - res = get_keyword_from_gradle_file(file_path, section, 'versionCode') - return res.to_i - end - - # Extract the value for a specific keyword in a specific section of a `.gradle` file - # - # @todo: This implementation is very fragile. This should be done parsing the file in a proper way. - # Leveraging gradle itself is probably the easiest way. - # - # @param [String] file_path The path of the `.gradle` file to extract the value from - # @param [String] section The name of the section from which we want to extract this keyword from. For example `defaultConfig` or `myFlavor` - # @param [String] keyword The keyword (key name) we want the value for - # - # @return [String] Returns the value for that keyword in the section of the `.gradle` file, or nil if not found. - # - def self.get_keyword_from_gradle_file(file_path, section, keyword) - found_section = false - File.open(file_path, 'r') do |file| - file.each_line do |line| - if !found_section - found_section = true if line.include?(section) - else - return line.split(' ')[1] if line.include?(keyword) && !line.include?("\"#{keyword}\"") && !line.include?("P#{keyword}") - end - end - end - return nil - end - # Ensure that a version string is correctly formatted (that is, each of its parts is a number) and returns the 2-parts version number # # @param [String] version The version string to verify @@ -426,62 +388,6 @@ def self.verify_version(version) def self.is_int? string true if Integer(string) rescue false end - - # The path to the build.gradle file for the project. - # - # @env PROJECT_ROOT_FOLDER The path to the root of the project (the folder containing the `.git` directory). - # @env PROJECT_NAME The name of the project, i.e. the name of the subdirectory containing the project's `build.gradle` file. - # - # @return [String] The path of the `build.gradle` file inside the project subfolder in the project's repo - # - def self.gradle_path - UI.user_error!("You need to set the \`PROJECT_ROOT_FOLDER\` environment variable to the path to the project's root") if ENV['PROJECT_ROOT_FOLDER'].nil? - UI.user_error!("You need to set the \`PROJECT_NAME\` environment variable to the relative path to the project subfolder name") if ENV['PROJECT_NAME'].nil? - File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'build.gradle') - end - - # Update both the versionName and versionCode of the build.gradle file to the specified version. - # - # @param [Hash] version The version hash, containing values for keys "name" and "code" - # @param [String] section The name of the section to update in the build.gradle file, e.g. "defaultConfig" or "vanilla" - # - # @todo This implementation is very fragile. This should be done parsing the file in a proper way. - # Leveraging gradle itself is probably the easiest way. - # - def self.update_version(version, section) - gradle_path = self.gradle_path - temp_file = Tempfile.new('fastlaneIncrementVersion') - found_section = false - version_updated = 0 - File.open(gradle_path, 'r') do |file| - file.each_line do |line| - if !found_section - temp_file.puts line - found_section = true if line.include? section - else - if version_updated < 2 - if line.include?('versionName') && !line.include?('"versionName"') && !line.include?('PversionName') - version_name = line.split(' ')[1].tr('\"', '') - line.sub!(version_name, version[VERSION_NAME].to_s) - version_updated = version_updated + 1 - end - - if line.include? 'versionCode' - version_code = line.split(' ')[1] - line.sub!(version_code, version[VERSION_CODE].to_s) - version_updated = version_updated + 1 - end - end - temp_file.puts line - end - end - file.close - end - temp_file.rewind - temp_file.close - FileUtils.mv(temp_file.path, gradle_path) - temp_file.unlink - end end end end From 31d91fbda81009472c81ae10f251730148b4bcb7 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 12 May 2021 14:11:02 -0500 Subject: [PATCH 06/57] update actions that were missed to include app param --- .../android/android_betabuild_prechecks.rb | 19 +++++++++++++------ .../android/android_build_prechecks.rb | 16 +++++++++++----- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb index 5a8da3982..0ab887d4d 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb @@ -11,11 +11,13 @@ def self.run(params) # Checkout develop and update Fastlane::Helper::GitHelper.checkout_and_pull('develop') + @app = params[:app] + # Check versions - release_version = Fastlane::Helper::Android::VersionHelper.get_release_version - message = "The following current version has been detected: #{release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}\n" - alpha_release_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version - message << "The following Alpha version has been detected: #{alpha_release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}\n" unless alpha_release_version.nil? + release_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) + message = "[#{@app}] The following current version has been detected: #{release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}\n" + alpha_release_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@app) + message << "[#{@app}] The following Alpha version has been detected: #{alpha_release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}\n" unless alpha_release_version.nil? # Check branch app_version = Fastlane::Helper::Android::VersionHelper.get_public_version @@ -48,9 +50,9 @@ def self.run(params) end def self.get_user_build_version(version, message) - UI.user_error!("Release branch for version #{version} doesn't exist. Abort.") unless Fastlane::Helper::GitHelper.checkout_and_pull(release: version) + UI.user_error!("[#{@app}] Release branch for version #{version} doesn't exist. Abort.") unless Fastlane::Helper::GitHelper.checkout_and_pull(release: version) release_version = Fastlane::Helper::Android::VersionHelper.get_release_version - message << "Looking at branch release/#{version} as requested by user. Detected version: #{release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}.\n" + message << "#{@app}] Looking at branch release/#{version} as requested by user. Detected version: #{release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}.\n" alpha_release_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version message << "and Alpha Version: #{alpha_release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}\n" unless alpha_release_version.nil? [release_version, alpha_release_version] @@ -80,6 +82,11 @@ def self.available_options description: 'Skips confirmation', is_string: false, # true: verifies the input is a string, false: every kind of value default_value: false), # the default value if the user didn't provide one + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb index 8cb12e567..43a8dbbd7 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb @@ -8,15 +8,16 @@ def self.run(params) Fastlane::Helper::GitHelper.ensure_on_branch!('release') unless other_action.is_ci() + app = params[:app] message = '' - beta_version = Fastlane::Helper::Android::VersionHelper.get_release_version() unless !params[:beta] && !params[:final] - alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version() if params[:alpha] + beta_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) unless !params[:beta] && !params[:final] + alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) if params[:alpha] UI.user_error!("Can't build a final release out of this branch because it's configured as a beta release!") if params[:final] && Fastlane::Helper::Android::VersionHelper.is_beta_version?(beta_version) - message << "Building version #{beta_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{beta_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}) (for upload to Release Channel)\n" if params[:final] - message << "Building version #{beta_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{beta_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}) (for upload to Beta Channel)\n" if params[:beta] - message << "Building version #{alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}) (for upload to Alpha Channel)\n" if params[:alpha] + message << "[#{app}] Building version #{beta_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{beta_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}) (for upload to Release Channel)\n" if params[:final] + message << "[#{app}] Building version #{beta_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{beta_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}) (for upload to Beta Channel)\n" if params[:beta] + message << "[#{app}] Building version #{alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}) (for upload to Alpha Channel)\n" if params[:alpha] if !params[:skip_confirm] UI.user_error!('Aborted by user request') unless UI.confirm("#{message}Do you want to continue?") @@ -62,6 +63,11 @@ def self.available_options description: 'True if this is for a final build', is_string: false, default_value: false), + FastlaneCore::ConfigItem.new(key: :app, + env_name: 'APP', + description: 'The app to get the release version for', + is_string: true, # true: verifies the input is a string, false: every kind of value + default_value: 'wordpress'), # the default value if the user didn't provide one ] end From 697bcf6c48c945ce42bf1d9e06498dc1c7bcd70d Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 12 May 2021 18:37:01 -0500 Subject: [PATCH 07/57] remove HAS_ALPHA env variable and fix inconsistencies with new app parameter --- .../android/android_build_prechecks.rb | 1 + .../android/android_bump_version_beta.rb | 8 +++---- .../android_bump_version_final_release.rb | 6 ++--- .../android/android_bump_version_hotfix.rb | 2 +- .../android/android_bump_version_release.rb | 2 +- .../android/android_codefreeze_prechecks.rb | 8 +++---- .../helper/android/android_version_helper.rb | 22 +++++++++++-------- .../plugin/wpmreleasetoolkit/version.rb | 2 +- 8 files changed, 28 insertions(+), 23 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb index 43a8dbbd7..adb022aea 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb @@ -3,6 +3,7 @@ module Actions class AndroidBuildPrechecksAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' + require_relative '../../helper/git_helper.rb' UI.user_error!("Can't build beta and final at the same time!") if params[:final] && params[:beta] diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index f2de9353b..4f7dcd096 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -59,20 +59,20 @@ def self.is_supported?(platform) private - def self.create_config(flavor) + def self.create_config @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@flavor) @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@flavor) @new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_beta_version(@current_version, @current_version_alpha) - @new_version_alpha = ENV['HAS_ALPHA_VERSION'].nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(@new_version_beta, @current_version_alpha) + @new_version_alpha = @current_version_alpha.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(@new_version_beta, @current_version_alpha) end def self.show_config vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE UI.message("Current version[#{@flavor}]: #{@current_version[vname]}(#{@current_version[vcode]})") - UI.message("Current alpha version[#{@flavor}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? + UI.message("Current alpha version[#{@flavor}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless @current_version_alpha.nil? UI.message("New beta version[#{@flavor}]: #{@new_version_beta[vname]}(#{@new_version_beta[vcode]})") - UI.message("New alpha version[#{@flavor}]: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? + UI.message("New alpha version[#{@flavor}]: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless @current_version_alpha.nil? end end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index 86ff25011..003c9da5f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -61,9 +61,9 @@ def self.create_config def self.show_config vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE - UI.message("Current version[#{{@flavor}}]: #{@current_version[vname]}(#{@current_version[vcode]})") - UI.message("Current alpha version[#{{@flavor}}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? - UI.message("New release version[#{{@flavor}}]: #{@final_version[vname]}(#{@final_version[vcode]})") + UI.message("Current version[#{@flavor}]: #{@current_version[vname]}(#{@current_version[vcode]})") + UI.message("Current alpha version[#{@flavor}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless @current_version_alpha.nil? + UI.message("New release version[#{@flavor}]: #{@final_version[vname]}(#{@final_version[vcode]})") end end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 7041d9152..13575f884 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -6,7 +6,7 @@ def self.run(params) require_relative '../../helper/android/android_git_helper.rb' Fastlane::Helper::GitHelper.create_branch("release/#{params[:version_name]}", from: params[:previous_version_name]) - + @flavor = params[:app] create_config(params[:previous_version_name], params[:version_name], params[:version_code]) show_config() diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index e25b1cb04..7fa7efdf6 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -11,8 +11,8 @@ def self.run(params) other_action.ensure_git_branch(branch: 'develop') # Create new configuration - @new_short_version = Fastlane::Helper::Android::VersionHelper.bump_version_release() @flavor = params[:app] + @new_short_version = Fastlane::Helper::Android::VersionHelper.bump_version_release(@flavor) create_config() show_config() diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb index badda5059..ff57b95af 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb @@ -20,14 +20,14 @@ def self.run(params) current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) current_alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) next_version = Fastlane::Helper::Android::VersionHelper.calc_next_release_version(current_version, current_alpha_version) - next_alpha_version = ENV['HAS_ALPHA_VERSION'].nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(next_version, current_alpha_version) + next_alpha_version = current_alpha_version.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(next_version, current_alpha_version) # Ask user confirmation unless params[:skip_confirm] confirm_message = "[#{params[:app]}]Building a new release branch starting from develop.\nCurrent version is #{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" - confirm_message += ENV['HAS_ALPHA_VERSION'].nil? ? "No alpha version configured.\n" : "Current Alpha version is #{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" + confirm_message += current_alpha_version.nil? ? "No alpha version configured. If you wish to configure an alpha version please update version.properties to include an alpha key for this flavor\n" : "Current Alpha version is #{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" confirm_message += "After codefreeze the new version will be: #{next_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{next_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" - confirm_message += ENV['HAS_ALPHA_VERSION'].nil? ? '' : "After codefreeze the new Alpha will be: #{next_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{next_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" + confirm_message += current_alpha_version.nil? ? '' : "After codefreeze the new Alpha will be: #{next_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{next_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" confirm_message += 'Do you want to continue?' UI.user_error!('Aborted by user request') unless UI.confirm(confirm_message) end @@ -36,7 +36,7 @@ def self.run(params) other_action.ensure_git_status_clean() # Return the current version - Fastlane::Helper::Android::VersionHelper.get_public_version + Fastlane::Helper::Android::VersionHelper.get_public_version(app) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 823d1cec5..4aaa8093e 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -31,7 +31,7 @@ module VersionHelper # - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number # def self.get_public_version(app) - version = get_version_from_flavor(app) + version = get_version_from_flavor(app, false) vp = get_version_parts(version[VERSION_NAME]) return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" unless is_hotfix?(version) @@ -46,7 +46,7 @@ def self.get_public_version(app) # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # def self.get_release_version(app) - return get_version_from_flavor(app, ENV['HAS_ALPHA_VERSION'].nil?) + return get_version_from_flavor(app, false) end # Extract the version name and code from a given secion of the `$PROJECT_NAME/build.gradle file` @@ -57,7 +57,8 @@ def self.get_version_from_flavor(flavor, isAlpha) version_name_key = "#{flavor}.#{isAlpha ? 'alpha.':''}versionName" version_code_key = "#{flavor}.#{isAlpha ? 'alpha.':''}versionCode" name = get_value_from_properties_file(version_name_key) - code = get_value_from_properties_file(version_code_key) + code = get_value_from_properties_file(version_code_key).to_i + return nil unless !(name.nil? || code.nil?) return { VERSION_NAME => name, VERSION_CODE => code } end @@ -78,7 +79,6 @@ def self.get_value_from_properties_file(key) # or `nil` if `$HAS_ALPHA_VERSION` is not defined. # def self.get_alpha_version(app) - return nil if ENV['HAS_ALPHA_VERSION'].nil? return get_version_from_flavor(app, true) end @@ -272,7 +272,7 @@ def self.is_hotfix?(version) # def self.bump_version_release(app) # Bump release - return bump_version_for_app(app, ENV['HAS_ALPHA_VERSION'].nil?) + return bump_version_for_app(app, false) end # Prints the current and next version names for a given section to stdout, then returns the next version @@ -297,10 +297,14 @@ def self.bump_version_for_app(app, isAlpha) # @env HAS_ALPHA_VERSION If set (with any value), indicates that the project uses `vanilla` flavor. # def self.update_versions(app, new_version_beta, new_version_alpha) - new_version_beta_key = "#{app}.versionName" - new_version_alpha_key = "#{app}.alpha.versionName" - Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_beta_key}", "-Pvalue=#{new_version_beta}") - Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_alpha_key}", "-Pvalue=#{new_version_alpha}") unless new_version_alpha.nil? + new_version_name_beta_key = "#{app}.versionName" + new_version_code_beta_key = "#{app}.versionCode" + new_version_name_alpha_key = "#{app}.alpha.versionName" + new_version_code_alpha_key = "#{app}.alpha.versionCode" + Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_name_beta_key}", "-Pvalue=#{new_version_beta[VERSION_NAME]}") + Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_code_beta_key}", "-Pvalue=#{new_version_beta[VERSION_CODE]}") + Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_name_alpha_key}", "-Pvalue=#{new_version_alpha[VERSION_NAME]}") unless new_version_alpha.nil? + Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_code_alpha_key}", "-Pvalue=#{new_version_alpha[VERSION_CODE]}") unless new_version_alpha.nil? end # Compute the name of the previous hotfix version. diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/version.rb index ee9c3a6c0..6bd4a8590 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/version.rb @@ -1,5 +1,5 @@ module Fastlane module Wpmreleasetoolkit - VERSION = '0.18.2' + VERSION = '0.18.1' end end From 679b33baacb3eca0bf88e07b88e3afcc2ad17fa0 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 12 May 2021 18:38:45 -0500 Subject: [PATCH 08/57] revert gemfile changes --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8ef24adc2..1e9728d12 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - fastlane-plugin-wpmreleasetoolkit (0.18.2) + fastlane-plugin-wpmreleasetoolkit (0.18.1) activesupport (~> 5) bigdecimal (~> 1.4) chroma (= 0.2.0) From 9f991bb9e57d6f4b4cb86351bb70230856ed9ce6 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 12 May 2021 19:30:47 -0500 Subject: [PATCH 09/57] clean up remaining env var uses --- .../actions/android/android_bump_version_final_release.rb | 2 +- .../actions/android/android_bump_version_hotfix.rb | 2 +- .../actions/android/android_bump_version_release.rb | 6 +++--- .../wpmreleasetoolkit/actions/android/android_tag_build.rb | 4 ++-- .../wpmreleasetoolkit/helper/android/android_git_helper.rb | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index 003c9da5f..6fd7cc237 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -12,7 +12,7 @@ def self.run(params) create_config() show_config() - UI.message 'Updating gradle.properties...' + UI.message 'Updating version.properties...' Fastlane::Helper::Android::VersionHelper.update_versions(@flavor, @final_version, @current_version_alpha) UI.message 'Done!' diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 13575f884..5ed4b9b8f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -11,7 +11,7 @@ def self.run(params) create_config(params[:previous_version_name], params[:version_name], params[:version_code]) show_config() - UI.message 'Updating build.gradle...' + UI.message 'Updating version.properties...' Fastlane::Helper::Android::VersionHelper.update_versions(@flavor, @new_version, @current_version_alpha) UI.message 'Done!' diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index 7fa7efdf6..95a596cfd 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -71,7 +71,7 @@ def self.create_config @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@flavor) @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@flavor) @new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_release_version(@current_version, @current_version_alpha) - @new_version_alpha = ENV['HAS_ALPHA_VERSION'].nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(@new_version_beta, @current_version_alpha) + @new_version_alpha = @current_version_alpha.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(@new_version_beta, @current_version_alpha) @new_release_branch = "release/#{@new_short_version}" end @@ -79,9 +79,9 @@ def self.show_config vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE UI.message("Current version[#{@flavor}]: #{@current_version[vname]}(#{@current_version[vcode]})") - UI.message("Current alpha version[#{@flavor}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? + UI.message("Current alpha version[#{@flavor}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless @current_version_alpha.nil? UI.message("New beta version[#{@flavor}]: #{@new_version_beta[vname]}(#{@new_version_beta[vcode]})") - UI.message("New alpha version[#{@flavor}]: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless ENV['HAS_ALPHA_VERSION'].nil? + UI.message("New alpha version[#{@flavor}]: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless @current_version_alpha.nil? UI.message("New version[#{@flavor}]: #{@new_short_version}") UI.message("Release branch: #{@new_release_branch}") end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb index 8f18c44d2..93c1e9788 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb @@ -8,9 +8,9 @@ def self.run(params) app = params[:app] release_ver = Fastlane::Helper::Android::VersionHelper.get_release_version(app) - alpha_ver = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) unless ENV['HAS_ALPHA_VERSION'].nil? + alpha_ver = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) Fastlane::Helper::GitHelper.create_tag(release_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]) - Fastlane::Helper::GitHelper.create_tag(alpha_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]) unless ENV['HAS_ALPHA_VERSION'].nil? || (params[:tag_alpha] == false) + Fastlane::Helper::GitHelper.create_tag(alpha_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]) unless alpha_ver.nil? || (params[:tag_alpha] == false) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb index 36dc4df7c..be1d0c45c 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb @@ -14,7 +14,7 @@ module GitHelper def self.commit_version_bump Fastlane::Helper::GitHelper.commit( message: 'Bump version number', - files: File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'build.gradle'), + files: File.join(ENV['PROJECT_ROOT_FOLDER'], 'version.properties'), push: true ) end From 67e007b1c55f196b7c39ee4362d75bfeb5c47eea Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 12 May 2021 19:42:38 -0500 Subject: [PATCH 10/57] address danger issues --- .../android/android_codefreeze_prechecks.rb | 5 +++-- .../android_completecodefreeze_prechecks.rb | 2 +- .../helper/android/android_version_helper.rb | 17 +++++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb index ff57b95af..10b22c686 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb @@ -15,17 +15,18 @@ def self.run(params) Fastlane::Helper::GitHelper.checkout_and_pull('develop') app = param[:app] - + # Create versions current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) current_alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) next_version = Fastlane::Helper::Android::VersionHelper.calc_next_release_version(current_version, current_alpha_version) next_alpha_version = current_alpha_version.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(next_version, current_alpha_version) + no_alpha_version_message = "No alpha version configured. If you wish to configure an alpha version please update version.properties to include an alpha key for this flavor\n" # Ask user confirmation unless params[:skip_confirm] confirm_message = "[#{params[:app]}]Building a new release branch starting from develop.\nCurrent version is #{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" - confirm_message += current_alpha_version.nil? ? "No alpha version configured. If you wish to configure an alpha version please update version.properties to include an alpha key for this flavor\n" : "Current Alpha version is #{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" + confirm_message += current_alpha_version.nil? ? no_alpha_version_message : "Current Alpha version is #{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" confirm_message += "After codefreeze the new version will be: #{next_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{next_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" confirm_message += current_alpha_version.nil? ? '' : "After codefreeze the new Alpha will be: #{next_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{next_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" confirm_message += 'Do you want to continue?' diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb index 119092ad7..c616e10ae 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb @@ -10,7 +10,7 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') app = params[:app] - + version = Fastlane::Helper::Android::VersionHelper.get_public_version(app) message = "Completing code freeze for: [#{app}]#{version}\n" unless params[:skip_confirm] diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 4aaa8093e..6098cfc88 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -53,21 +53,22 @@ def self.get_release_version(app) # # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # - def self.get_version_from_flavor(flavor, isAlpha) - version_name_key = "#{flavor}.#{isAlpha ? 'alpha.':''}versionName" - version_code_key = "#{flavor}.#{isAlpha ? 'alpha.':''}versionCode" + def self.get_version_from_flavor(flavor, is_alpha) + version_name_key = "#{flavor}.#{is_alpha ? 'alpha.' : ''}versionName" + version_code_key = "#{flavor}.#{is_alpha ? 'alpha.' : ''}versionCode" name = get_value_from_properties_file(version_name_key) code = get_value_from_properties_file(version_code_key).to_i - return nil unless !(name.nil? || code.nil?) + if (name.nil? || code.nil?) return nil + return { VERSION_NAME => name, VERSION_CODE => code } end def self.get_value_from_properties_file(key) properties_file_path = File.join(ENV['PROJECT_ROOT_FOLDER'] || '.', 'version.properties') - return nil unless File.exists?(properties_file_path) + return nil unless File.exist?(properties_file_path) - File.open(properties_file_path, 'r') do | f | + File.open(properties_file_path, 'r') do |f| text = f.read text.match(/#{key}=(\S*)/m)&.captures&.first end @@ -279,9 +280,9 @@ def self.bump_version_release(app) # # @return [String] The next version name to use after bumping the currently used version. # - def self.bump_version_for_app(app, isAlpha) + def self.bump_version_for_app(app, is_alpha) # Bump release - current_version = get_version_from_flavor(app, isAlpha) + current_version = get_version_from_flavor(app, is_alpha) UI.message("Current version: #{current_version[VERSION_NAME]}") new_version = calc_next_release_base_version(current_version) UI.message("New version: #{new_version[VERSION_NAME]}") From fb99670927229d67724e76eb9189db1929e6d239 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 12 May 2021 19:44:26 -0500 Subject: [PATCH 11/57] address danger issues --- .../actions/android/android_codefreeze_prechecks.rb | 2 +- .../wpmreleasetoolkit/helper/android/android_version_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb index 10b22c686..822c80e0c 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb @@ -15,7 +15,7 @@ def self.run(params) Fastlane::Helper::GitHelper.checkout_and_pull('develop') app = param[:app] - + # Create versions current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) current_alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 6098cfc88..185782586 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -58,7 +58,7 @@ def self.get_version_from_flavor(flavor, is_alpha) version_code_key = "#{flavor}.#{is_alpha ? 'alpha.' : ''}versionCode" name = get_value_from_properties_file(version_name_key) code = get_value_from_properties_file(version_code_key).to_i - if (name.nil? || code.nil?) return nil + return nil if (name.nil? || code.nil?) return { VERSION_NAME => name, VERSION_CODE => code } end From 89194c3bd0ce48e4f7e66e1583317bea8a5999be Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 12 May 2021 20:23:21 -0500 Subject: [PATCH 12/57] address danger issues --- .../wpmreleasetoolkit/helper/android/android_version_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 185782586..ed0696358 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -58,7 +58,7 @@ def self.get_version_from_flavor(flavor, is_alpha) version_code_key = "#{flavor}.#{is_alpha ? 'alpha.' : ''}versionCode" name = get_value_from_properties_file(version_name_key) code = get_value_from_properties_file(version_code_key).to_i - return nil if (name.nil? || code.nil?) + return nil if name.nil? || code.nil? return { VERSION_NAME => name, VERSION_CODE => code } end From 4135aa908f56d7a502a28f9ae879ea55ab7eb4d4 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 13 May 2021 11:48:07 -0500 Subject: [PATCH 13/57] allow for the use of relase flavor env var --- .../actions/android/android_betabuild_prechecks.rb | 2 +- .../actions/android/android_build_prechecks.rb | 2 +- .../actions/android/android_bump_version_beta.rb | 4 ++-- .../actions/android/android_bump_version_final_release.rb | 2 +- .../actions/android/android_bump_version_hotfix.rb | 2 +- .../actions/android/android_bump_version_release.rb | 4 ++-- .../actions/android/android_codefreeze_prechecks.rb | 4 ++-- .../actions/android/android_completecodefreeze_prechecks.rb | 2 +- .../actions/android/android_current_branch_is_hotfix.rb | 3 ++- .../actions/android/android_finalize_prechecks.rb | 3 ++- .../actions/android/android_get_alpha_version.rb | 3 ++- .../actions/android/android_get_app_version.rb | 3 ++- .../actions/android/android_get_release_version.rb | 3 ++- .../wpmreleasetoolkit/actions/android/android_tag_build.rb | 6 +++--- 14 files changed, 24 insertions(+), 19 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb index 0ab887d4d..881447147 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb @@ -11,7 +11,7 @@ def self.run(params) # Checkout develop and update Fastlane::Helper::GitHelper.checkout_and_pull('develop') - @app = params[:app] + @app = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] # Check versions release_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb index adb022aea..6f71134ad 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb @@ -9,7 +9,7 @@ def self.run(params) Fastlane::Helper::GitHelper.ensure_on_branch!('release') unless other_action.is_ci() - app = params[:app] + app = ENV['RELEASE_FLAVOR'].nil? ? params[:app]: ENV['RELEASE_FLAVOR'] message = '' beta_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) unless !params[:beta] && !params[:final] alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) if params[:alpha] diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index 4f7dcd096..36ecd8f13 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -8,13 +8,13 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' Fastlane::Helper::GitHelper.ensure_on_branch!('release') - @flavor = params[:app] + @flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] create_config() show_config() UI.message 'Updating build.gradle...' - Fastlane::Helper::Android::VersionHelper.update_versions(params[:app], @new_version_beta, @new_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(@flavor, @new_version_beta, @new_version_alpha) UI.message 'Done!' Fastlane::Helper::Android::GitHelper.commit_version_bump() diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index 6fd7cc237..04827a228 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -8,7 +8,7 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' Fastlane::Helper::GitHelper.ensure_on_branch!('release') - @flavor = params[:app] + @flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] create_config() show_config() diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 5ed4b9b8f..6e1a62009 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -7,7 +7,7 @@ def self.run(params) require_relative '../../helper/android/android_git_helper.rb' Fastlane::Helper::GitHelper.create_branch("release/#{params[:version_name]}", from: params[:previous_version_name]) - @flavor = params[:app] + @flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] create_config(params[:previous_version_name], params[:version_name], params[:version_code]) show_config() diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index 95a596cfd..4a99b0b05 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -11,7 +11,7 @@ def self.run(params) other_action.ensure_git_branch(branch: 'develop') # Create new configuration - @flavor = params[:app] + @flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] @new_short_version = Fastlane::Helper::Android::VersionHelper.bump_version_release(@flavor) create_config() @@ -23,7 +23,7 @@ def self.run(params) UI.message 'Done!' UI.message 'Updating versions...' - Fastlane::Helper::Android::VersionHelper.update_versions(params[:app], @new_version_beta, @new_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(@flavor, @new_version_beta, @new_version_alpha) Fastlane::Helper::Android::GitHelper.commit_version_bump() UI.message 'Done.' end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb index 822c80e0c..b49a7a4dc 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb @@ -14,7 +14,7 @@ def self.run(params) # Checkout develop and update Fastlane::Helper::GitHelper.checkout_and_pull('develop') - app = param[:app] + app = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] # Create versions current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) @@ -25,7 +25,7 @@ def self.run(params) no_alpha_version_message = "No alpha version configured. If you wish to configure an alpha version please update version.properties to include an alpha key for this flavor\n" # Ask user confirmation unless params[:skip_confirm] - confirm_message = "[#{params[:app]}]Building a new release branch starting from develop.\nCurrent version is #{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" + confirm_message = "[#{app}]Building a new release branch starting from develop.\nCurrent version is #{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" confirm_message += current_alpha_version.nil? ? no_alpha_version_message : "Current Alpha version is #{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" confirm_message += "After codefreeze the new version will be: #{next_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{next_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" confirm_message += current_alpha_version.nil? ? '' : "After codefreeze the new Alpha will be: #{next_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{next_alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb index c616e10ae..7e674c65c 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb @@ -9,7 +9,7 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') - app = params[:app] + app = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] version = Fastlane::Helper::Android::VersionHelper.get_public_version(app) message = "Completing code freeze for: [#{app}]#{version}\n" diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb index 30abab1a0..f16b6c86a 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb @@ -7,7 +7,8 @@ module SharedValues class AndroidCurrentBranchIsHotfixAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - Fastlane::Helper::Android::VersionHelper.is_hotfix?(Fastlane::Helper::Android::VersionHelper.get_release_version(params[:app])) + flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + Fastlane::Helper::Android::VersionHelper.is_hotfix?(Fastlane::Helper::Android::VersionHelper.get_release_version(flavor)) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb index b895749c4..af2349f55 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb @@ -13,7 +13,8 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') - version = Fastlane::Helper::Android::VersionHelper.get_public_version(params[:app]) + flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + version = Fastlane::Helper::Android::VersionHelper.get_public_version(flavor) message = "Finalizing release: #{version}\n" if !params[:skip_confirm] UI.user_error!('Aborted by user request') unless UI.confirm("#{message}Do you want to continue?") diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb index 6155e8129..12145e804 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb @@ -3,7 +3,8 @@ module Actions class AndroidGetAlphaVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - Fastlane::Helper::Android::VersionHelper.get_alpha_version(params[:app]) + flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + Fastlane::Helper::Android::VersionHelper.get_alpha_version(flavor) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb index fea52026d..48e87ab52 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb @@ -3,7 +3,8 @@ module Actions class AndroidGetAppVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - Fastlane::Helper::Android::VersionHelper.get_public_version(params[:app]) + flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + Fastlane::Helper::Android::VersionHelper.get_public_version(flavor) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index 461722d10..592e97000 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -3,7 +3,8 @@ module Actions class AndroidGetReleaseVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - Fastlane::Helper::Android::VersionHelper.get_release_version(params[:app]) + flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + Fastlane::Helper::Android::VersionHelper.get_release_version(flavor) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb index 93c1e9788..cb69691ae 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb @@ -5,10 +5,10 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' require_relative '../../helper/android/android_git_helper.rb' - app = params[:app] + flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] - release_ver = Fastlane::Helper::Android::VersionHelper.get_release_version(app) - alpha_ver = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) + release_ver = Fastlane::Helper::Android::VersionHelper.get_release_version(flavor) + alpha_ver = Fastlane::Helper::Android::VersionHelper.get_alpha_version(flavor) Fastlane::Helper::GitHelper.create_tag(release_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]) Fastlane::Helper::GitHelper.create_tag(alpha_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]) unless alpha_ver.nil? || (params[:tag_alpha] == false) end From b95e5e2c188587d240fcf43e55245035f921f586 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 13 May 2021 12:03:37 -0500 Subject: [PATCH 14/57] change env var name --- .../actions/android/android_betabuild_prechecks.rb | 2 +- .../actions/android/android_build_prechecks.rb | 2 +- .../actions/android/android_bump_version_beta.rb | 2 +- .../actions/android/android_bump_version_final_release.rb | 2 +- .../actions/android/android_bump_version_hotfix.rb | 2 +- .../actions/android/android_bump_version_release.rb | 2 +- .../actions/android/android_codefreeze_prechecks.rb | 2 +- .../actions/android/android_completecodefreeze_prechecks.rb | 2 +- .../actions/android/android_current_branch_is_hotfix.rb | 2 +- .../actions/android/android_finalize_prechecks.rb | 2 +- .../actions/android/android_get_alpha_version.rb | 2 +- .../actions/android/android_get_app_version.rb | 2 +- .../actions/android/android_get_release_version.rb | 2 +- .../wpmreleasetoolkit/actions/android/android_tag_build.rb | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb index 881447147..341593d94 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb @@ -11,7 +11,7 @@ def self.run(params) # Checkout develop and update Fastlane::Helper::GitHelper.checkout_and_pull('develop') - @app = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + @app = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] # Check versions release_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb index 6f71134ad..b7f875666 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb @@ -9,7 +9,7 @@ def self.run(params) Fastlane::Helper::GitHelper.ensure_on_branch!('release') unless other_action.is_ci() - app = ENV['RELEASE_FLAVOR'].nil? ? params[:app]: ENV['RELEASE_FLAVOR'] + app = ENV['PRODUCT_NAME'].nil? ? params[:app]: ENV['PRODUCT_NAME'] message = '' beta_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) unless !params[:beta] && !params[:final] alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) if params[:alpha] diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index 36ecd8f13..5bc0f344e 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -8,7 +8,7 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' Fastlane::Helper::GitHelper.ensure_on_branch!('release') - @flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + @flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] create_config() show_config() diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index 04827a228..fe137233f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -8,7 +8,7 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' Fastlane::Helper::GitHelper.ensure_on_branch!('release') - @flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + @flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] create_config() show_config() diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 6e1a62009..302662d8b 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -7,7 +7,7 @@ def self.run(params) require_relative '../../helper/android/android_git_helper.rb' Fastlane::Helper::GitHelper.create_branch("release/#{params[:version_name]}", from: params[:previous_version_name]) - @flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + @flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] create_config(params[:previous_version_name], params[:version_name], params[:version_code]) show_config() diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index 4a99b0b05..4514bc6a3 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -11,7 +11,7 @@ def self.run(params) other_action.ensure_git_branch(branch: 'develop') # Create new configuration - @flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + @flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] @new_short_version = Fastlane::Helper::Android::VersionHelper.bump_version_release(@flavor) create_config() diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb index b49a7a4dc..8a3a5008f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb @@ -14,7 +14,7 @@ def self.run(params) # Checkout develop and update Fastlane::Helper::GitHelper.checkout_and_pull('develop') - app = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + app = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] # Create versions current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb index 7e674c65c..d95d69ad1 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb @@ -9,7 +9,7 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') - app = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + app = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] version = Fastlane::Helper::Android::VersionHelper.get_public_version(app) message = "Completing code freeze for: [#{app}]#{version}\n" diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb index f16b6c86a..f3c1f0c03 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb @@ -7,7 +7,7 @@ module SharedValues class AndroidCurrentBranchIsHotfixAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] Fastlane::Helper::Android::VersionHelper.is_hotfix?(Fastlane::Helper::Android::VersionHelper.get_release_version(flavor)) end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb index af2349f55..0474dd2bf 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb @@ -13,7 +13,7 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') - flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] version = Fastlane::Helper::Android::VersionHelper.get_public_version(flavor) message = "Finalizing release: #{version}\n" if !params[:skip_confirm] diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb index 12145e804..cec4bd331 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb @@ -3,7 +3,7 @@ module Actions class AndroidGetAlphaVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] Fastlane::Helper::Android::VersionHelper.get_alpha_version(flavor) end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb index 48e87ab52..7d1ddd86b 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb @@ -3,7 +3,7 @@ module Actions class AndroidGetAppVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] Fastlane::Helper::Android::VersionHelper.get_public_version(flavor) end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index 592e97000..e30e53c08 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -3,7 +3,7 @@ module Actions class AndroidGetReleaseVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] Fastlane::Helper::Android::VersionHelper.get_release_version(flavor) end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb index cb69691ae..5334fc45c 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb @@ -5,7 +5,7 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' require_relative '../../helper/android/android_git_helper.rb' - flavor = ENV['RELEASE_FLAVOR'].nil? ? params[:app] : ENV['RELEASE_FLAVOR'] + flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] release_ver = Fastlane::Helper::Android::VersionHelper.get_release_version(flavor) alpha_ver = Fastlane::Helper::Android::VersionHelper.get_alpha_version(flavor) From e587c663e9ade1a9aa04287c2470202414704c4e Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 13 May 2021 12:16:21 -0500 Subject: [PATCH 15/57] update naming and comments to be more consistent --- .../android/android_betabuild_prechecks.rb | 2 +- .../android/android_build_prechecks.rb | 2 +- .../android/android_bump_version_beta.rb | 16 ++++----- .../android_bump_version_final_release.rb | 14 ++++---- .../android/android_bump_version_hotfix.rb | 12 +++---- .../android/android_bump_version_release.rb | 20 +++++------ .../android/android_codefreeze_prechecks.rb | 4 +-- .../android_completecodefreeze_prechecks.rb | 2 +- .../android_current_branch_is_hotfix.rb | 4 +-- .../android/android_finalize_prechecks.rb | 4 +-- .../android/android_get_alpha_version.rb | 4 +-- .../android/android_get_app_version.rb | 4 +-- .../android/android_get_release_version.rb | 4 +-- .../actions/android/android_tag_build.rb | 6 ++-- .../helper/android/android_version_helper.rb | 34 ++++++++----------- 15 files changed, 64 insertions(+), 68 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb index 341593d94..6518c29d5 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb @@ -11,7 +11,7 @@ def self.run(params) # Checkout develop and update Fastlane::Helper::GitHelper.checkout_and_pull('develop') - @app = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] + @app = ENV['APP'].nil? ? params[:app] : ENV['APP'] # Check versions release_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb index b7f875666..3478a25f2 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb @@ -9,7 +9,7 @@ def self.run(params) Fastlane::Helper::GitHelper.ensure_on_branch!('release') unless other_action.is_ci() - app = ENV['PRODUCT_NAME'].nil? ? params[:app]: ENV['PRODUCT_NAME'] + app = ENV['APP'].nil? ? params[:app]: ENV['APP'] message = '' beta_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) unless !params[:beta] && !params[:final] alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) if params[:alpha] diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index 5bc0f344e..a98c50200 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -8,13 +8,13 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' Fastlane::Helper::GitHelper.ensure_on_branch!('release') - @flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] + @app = ENV['APP'].nil? ? params[:app] : ENV['APP'] create_config() show_config() UI.message 'Updating build.gradle...' - Fastlane::Helper::Android::VersionHelper.update_versions(@flavor, @new_version_beta, @new_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(@app, @new_version_beta, @new_version_alpha) UI.message 'Done!' Fastlane::Helper::Android::GitHelper.commit_version_bump() @@ -60,8 +60,8 @@ def self.is_supported?(platform) private def self.create_config - @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@flavor) - @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@flavor) + @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) + @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@app) @new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_beta_version(@current_version, @current_version_alpha) @new_version_alpha = @current_version_alpha.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(@new_version_beta, @current_version_alpha) end @@ -69,10 +69,10 @@ def self.create_config def self.show_config vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE - UI.message("Current version[#{@flavor}]: #{@current_version[vname]}(#{@current_version[vcode]})") - UI.message("Current alpha version[#{@flavor}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless @current_version_alpha.nil? - UI.message("New beta version[#{@flavor}]: #{@new_version_beta[vname]}(#{@new_version_beta[vcode]})") - UI.message("New alpha version[#{@flavor}]: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless @current_version_alpha.nil? + UI.message("Current version[#{@app}]: #{@current_version[vname]}(#{@current_version[vcode]})") + UI.message("Current alpha version[#{@app}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless @current_version_alpha.nil? + UI.message("New beta version[#{@app}]: #{@new_version_beta[vname]}(#{@new_version_beta[vcode]})") + UI.message("New alpha version[#{@app}]: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless @current_version_alpha.nil? end end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index fe137233f..a317baeb7 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -8,12 +8,12 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' Fastlane::Helper::GitHelper.ensure_on_branch!('release') - @flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] + @app = ENV['APP'].nil? ? params[:app] : ENV['APP'] create_config() show_config() UI.message 'Updating version.properties...' - Fastlane::Helper::Android::VersionHelper.update_versions(@flavor, @final_version, @current_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(@app, @final_version, @current_version_alpha) UI.message 'Done!' Fastlane::Helper::Android::GitHelper.commit_version_bump() @@ -53,17 +53,17 @@ def self.is_supported?(platform) private def self.create_config - @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@flavor) - @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@flavor) + @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) + @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@app) @final_version = Fastlane::Helper::Android::VersionHelper.calc_final_release_version(@current_version, @current_version_alpha) end def self.show_config vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE - UI.message("Current version[#{@flavor}]: #{@current_version[vname]}(#{@current_version[vcode]})") - UI.message("Current alpha version[#{@flavor}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless @current_version_alpha.nil? - UI.message("New release version[#{@flavor}]: #{@final_version[vname]}(#{@final_version[vcode]})") + UI.message("Current version[#{@app}]: #{@current_version[vname]}(#{@current_version[vcode]})") + UI.message("Current alpha version[#{@app}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless @current_version_alpha.nil? + UI.message("New release version[#{@app}]: #{@final_version[vname]}(#{@final_version[vcode]})") end end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 302662d8b..329ad5097 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -7,12 +7,12 @@ def self.run(params) require_relative '../../helper/android/android_git_helper.rb' Fastlane::Helper::GitHelper.create_branch("release/#{params[:version_name]}", from: params[:previous_version_name]) - @flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] + @app = ENV['APP'].nil? ? params[:app] : ENV['APP'] create_config(params[:previous_version_name], params[:version_name], params[:version_code]) show_config() UI.message 'Updating version.properties...' - Fastlane::Helper::Android::VersionHelper.update_versions(@flavor, @new_version, @current_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(@app, @new_version, @current_version_alpha) UI.message 'Done!' Fastlane::Helper::Android::GitHelper.commit_version_bump() @@ -67,16 +67,16 @@ def self.is_supported?(platform) private def self.create_config(previous_version, new_version_name, new_version_code) - @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@flavor) - @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@flavor) + @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) + @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@app) @new_version = Fastlane::Helper::Android::VersionHelper.calc_next_hotfix_version(new_version_name, new_version_code) @new_short_version = new_version_name @new_release_branch = "release/#{@new_short_version}" end def self.show_config - UI.message("Current version[#{@flavor}]: #{@current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{@current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") - UI.message("New hotfix version[#{@flavor}]: #{@new_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{@new_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") + UI.message("Current version[#{@app}]: #{@current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{@current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") + UI.message("New hotfix version[#{@app}]: #{@new_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{@new_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") UI.message("Release branch: #{@new_release_branch}") end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index 4514bc6a3..ab97f5a28 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -11,8 +11,8 @@ def self.run(params) other_action.ensure_git_branch(branch: 'develop') # Create new configuration - @flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] - @new_short_version = Fastlane::Helper::Android::VersionHelper.bump_version_release(@flavor) + @app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + @new_short_version = Fastlane::Helper::Android::VersionHelper.bump_version_release(@app) create_config() show_config() @@ -23,7 +23,7 @@ def self.run(params) UI.message 'Done!' UI.message 'Updating versions...' - Fastlane::Helper::Android::VersionHelper.update_versions(@flavor, @new_version_beta, @new_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(@app, @new_version_beta, @new_version_alpha) Fastlane::Helper::Android::GitHelper.commit_version_bump() UI.message 'Done.' end @@ -68,8 +68,8 @@ def self.is_supported?(platform) private def self.create_config - @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@flavor) - @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@flavor) + @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) + @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@app) @new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_release_version(@current_version, @current_version_alpha) @new_version_alpha = @current_version_alpha.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(@new_version_beta, @current_version_alpha) @new_release_branch = "release/#{@new_short_version}" @@ -78,11 +78,11 @@ def self.create_config def self.show_config vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE - UI.message("Current version[#{@flavor}]: #{@current_version[vname]}(#{@current_version[vcode]})") - UI.message("Current alpha version[#{@flavor}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless @current_version_alpha.nil? - UI.message("New beta version[#{@flavor}]: #{@new_version_beta[vname]}(#{@new_version_beta[vcode]})") - UI.message("New alpha version[#{@flavor}]: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless @current_version_alpha.nil? - UI.message("New version[#{@flavor}]: #{@new_short_version}") + UI.message("Current version[#{@app}]: #{@current_version[vname]}(#{@current_version[vcode]})") + UI.message("Current alpha version[#{@app}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless @current_version_alpha.nil? + UI.message("New beta version[#{@app}]: #{@new_version_beta[vname]}(#{@new_version_beta[vcode]})") + UI.message("New alpha version[#{@app}]: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless @current_version_alpha.nil? + UI.message("New version[#{@app}]: #{@new_short_version}") UI.message("Release branch: #{@new_release_branch}") end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb index 8a3a5008f..6247a996d 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb @@ -14,7 +14,7 @@ def self.run(params) # Checkout develop and update Fastlane::Helper::GitHelper.checkout_and_pull('develop') - app = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] + app = ENV['APP'].nil? ? params[:app] : ENV['APP'] # Create versions current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) @@ -22,7 +22,7 @@ def self.run(params) next_version = Fastlane::Helper::Android::VersionHelper.calc_next_release_version(current_version, current_alpha_version) next_alpha_version = current_alpha_version.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(next_version, current_alpha_version) - no_alpha_version_message = "No alpha version configured. If you wish to configure an alpha version please update version.properties to include an alpha key for this flavor\n" + no_alpha_version_message = "No alpha version configured. If you wish to configure an alpha version please update version.properties to include an alpha key for this app\n" # Ask user confirmation unless params[:skip_confirm] confirm_message = "[#{app}]Building a new release branch starting from develop.\nCurrent version is #{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]} (#{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}).\n" diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb index d95d69ad1..4745b3365 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb @@ -9,7 +9,7 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') - app = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] + app = ENV['APP'].nil? ? params[:app] : ENV['APP'] version = Fastlane::Helper::Android::VersionHelper.get_public_version(app) message = "Completing code freeze for: [#{app}]#{version}\n" diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb index f3c1f0c03..a70f59423 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb @@ -7,8 +7,8 @@ module SharedValues class AndroidCurrentBranchIsHotfixAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] - Fastlane::Helper::Android::VersionHelper.is_hotfix?(Fastlane::Helper::Android::VersionHelper.get_release_version(flavor)) + app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + Fastlane::Helper::Android::VersionHelper.is_hotfix?(Fastlane::Helper::Android::VersionHelper.get_release_version(app)) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb index 0474dd2bf..1c5394aea 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb @@ -13,8 +13,8 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') - flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] - version = Fastlane::Helper::Android::VersionHelper.get_public_version(flavor) + app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + version = Fastlane::Helper::Android::VersionHelper.get_public_version(app) message = "Finalizing release: #{version}\n" if !params[:skip_confirm] UI.user_error!('Aborted by user request') unless UI.confirm("#{message}Do you want to continue?") diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb index cec4bd331..2363a5098 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb @@ -3,8 +3,8 @@ module Actions class AndroidGetAlphaVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] - Fastlane::Helper::Android::VersionHelper.get_alpha_version(flavor) + app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb index 7d1ddd86b..742a07846 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb @@ -3,8 +3,8 @@ module Actions class AndroidGetAppVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] - Fastlane::Helper::Android::VersionHelper.get_public_version(flavor) + app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + Fastlane::Helper::Android::VersionHelper.get_public_version(app) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index e30e53c08..0069c069d 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -3,8 +3,8 @@ module Actions class AndroidGetReleaseVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] - Fastlane::Helper::Android::VersionHelper.get_release_version(flavor) + app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + Fastlane::Helper::Android::VersionHelper.get_release_version(app) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb index 5334fc45c..7cc16cbb5 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb @@ -5,10 +5,10 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' require_relative '../../helper/android/android_git_helper.rb' - flavor = ENV['PRODUCT_NAME'].nil? ? params[:app] : ENV['PRODUCT_NAME'] + app = ENV['APP'].nil? ? params[:app] : ENV['APP'] - release_ver = Fastlane::Helper::Android::VersionHelper.get_release_version(flavor) - alpha_ver = Fastlane::Helper::Android::VersionHelper.get_alpha_version(flavor) + release_ver = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + alpha_ver = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) Fastlane::Helper::GitHelper.create_tag(release_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]) Fastlane::Helper::GitHelper.create_tag(alpha_ver[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]) unless alpha_ver.nil? || (params[:tag_alpha] == false) end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index ed0696358..903d9d1ca 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -31,31 +31,28 @@ module VersionHelper # - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number # def self.get_public_version(app) - version = get_version_from_flavor(app, false) + version = get_version_from_properties(app, false) vp = get_version_parts(version[VERSION_NAME]) return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" unless is_hotfix?(version) "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}" end - # Extract the version name and code from the flavor of the `$PROJECT_NAME/build.gradle file` - # or for the defaultConfig if `HAS_ALPHA_VERSION` is not defined. - # - # @env HAS_ALPHA_VERSION If set (with any value), indicates that the project uses `vanilla` flavor. + # Extract the version name and code from the release version of the app from `version.properties file` # # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # def self.get_release_version(app) - return get_version_from_flavor(app, false) + return get_version_from_properties(app, false) end - # Extract the version name and code from a given secion of the `$PROJECT_NAME/build.gradle file` + # Extract the version name and code from the `version.properties` file in the project root # # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # - def self.get_version_from_flavor(flavor, is_alpha) - version_name_key = "#{flavor}.#{is_alpha ? 'alpha.' : ''}versionName" - version_code_key = "#{flavor}.#{is_alpha ? 'alpha.' : ''}versionCode" + def self.get_version_from_properties(product_name, is_alpha) + version_name_key = "#{product_name}.#{is_alpha ? 'alpha.' : ''}versionName" + version_code_key = "#{product_name}.#{is_alpha ? 'alpha.' : ''}versionCode" name = get_value_from_properties_file(version_name_key) code = get_value_from_properties_file(version_code_key).to_i return nil if name.nil? || code.nil? @@ -74,13 +71,13 @@ def self.get_value_from_properties_file(key) end end - # Extract the version name and code from the `defaultConfig` of the `$PROJECT_NAME/build.gradle` file + # Extract the version name and code from the `version.properties` file in the project root # # @return [Hash] A hash with 2 keys `"name"` and `"code"` containing the extracted version name and code, respectively, # or `nil` if `$HAS_ALPHA_VERSION` is not defined. # def self.get_alpha_version(app) - return get_version_from_flavor(app, true) + return get_version_from_properties(app, true) end # Determines if a version name corresponds to an alpha version (starts with `"alpha-"`` prefix) @@ -110,8 +107,8 @@ def self.is_beta_version?(version) # - The final version name corresponds to the beta's versionName, without the `-rc` suffix # - The final version code corresponds to the versionCode for the alpha (or for the beta if alpha_version is nil) incremented by one. # - # @param [Hash] beta_version The version hash for the beta (vanilla flavor), containing values for keys "name" and "code" - # @param [Hash] alpha_version The version hash for the alpha (defaultConfig), containing values for keys "name" and "code", + # @param [Hash] beta_version The version hash for the beta, containing values for keys "name" and "code" + # @param [Hash] alpha_version The version hash for the alpha, containing values for keys "name" and "code", # or `nil` if no alpha version to consider. # # @return [Hash] A version hash with keys "name" and "code", containing the version name and code to use for final release. @@ -282,7 +279,7 @@ def self.bump_version_release(app) # def self.bump_version_for_app(app, is_alpha) # Bump release - current_version = get_version_from_flavor(app, is_alpha) + current_version = get_version_from_properties(app, is_alpha) UI.message("Current version: #{current_version[VERSION_NAME]}") new_version = calc_next_release_base_version(current_version) UI.message("New version: #{new_version[VERSION_NAME]}") @@ -291,11 +288,10 @@ def self.bump_version_for_app(app, is_alpha) return verified_version end - # Update the `build.gradle` file with new `versionName` and `versionCode` values, both or the `defaultConfig` and `vanilla` flavors + # Update the `version.properties` file with new `versionName` and `versionCode` values # - # @param [Hash] new_version_beta The version hash for the beta (vanilla flavor), containing values for keys "name" and "code" - # @param [Hash] new_version_alpha The version hash for the alpha (defaultConfig), containing values for keys "name" and "code" - # @env HAS_ALPHA_VERSION If set (with any value), indicates that the project uses `vanilla` flavor. + # @param [Hash] new_version_beta The version hash for the beta, containing values for keys "name" and "code" + # @param [Hash] new_version_alpha The version hash for the alpha , containing values for keys "name" and "code" # def self.update_versions(app, new_version_beta, new_version_alpha) new_version_name_beta_key = "#{app}.versionName" From 17788b096c02014684f7ed4f227a683068a417fd Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 13 May 2021 13:02:16 -0500 Subject: [PATCH 16/57] add tests around new version properties logic --- .../helper/android/android_version_helper.rb | 16 ++++---- spec/android_version_helper_spec.rb | 38 +++++++++++++++++++ 2 files changed, 46 insertions(+), 8 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 903d9d1ca..ee34648c2 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -53,21 +53,21 @@ def self.get_release_version(app) def self.get_version_from_properties(product_name, is_alpha) version_name_key = "#{product_name}.#{is_alpha ? 'alpha.' : ''}versionName" version_code_key = "#{product_name}.#{is_alpha ? 'alpha.' : ''}versionCode" - name = get_value_from_properties_file(version_name_key) - code = get_value_from_properties_file(version_code_key).to_i - return nil if name.nil? || code.nil? - return { VERSION_NAME => name, VERSION_CODE => code } - end - - def self.get_value_from_properties_file(key) properties_file_path = File.join(ENV['PROJECT_ROOT_FOLDER'] || '.', 'version.properties') return nil unless File.exist?(properties_file_path) File.open(properties_file_path, 'r') do |f| text = f.read - text.match(/#{key}=(\S*)/m)&.captures&.first + name = text.match(/#{version_name_key}=(\S*)/m)&.captures&.first + code = text.match(/#{version_code_key}=(\S*)/m)&.captures&.first + + f.close + + return nil if name.nil? || code.nil? + + return { VERSION_NAME => name, VERSION_CODE => code.to_i } end end diff --git a/spec/android_version_helper_spec.rb b/spec/android_version_helper_spec.rb index 9c056c7c6..acd2a73bf 100644 --- a/spec/android_version_helper_spec.rb +++ b/spec/android_version_helper_spec.rb @@ -1,6 +1,44 @@ require 'spec_helper.rb' describe Fastlane::Helper::Android::VersionHelper do + describe 'get_version_from_properties' do + it 'returns version name and code when present' do + test_file_content = <<~CONTENT + wordpress.versionName=17.0 + wordpress.versionCode=123 + wordpress.alpha.versionName=alpha-222 + wordpress.alpha.versionCode=1234 + CONTENT + + allow(File).to receive(:exist?).and_return(true) + allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) + expect(subject.get_version_from_properties('wordpress', false)).to eq({'name' => "17.0", 'code' => 123}) + end + + it 'returns alpha version name and code when present' do + test_file_content = <<~CONTENT + wordpress.versionName=17.0 + wordpress.versionCode=123 + wordpress.alpha.versionName=alpha-222 + wordpress.alpha.versionCode=1234 + CONTENT + + allow(File).to receive(:exist?).and_return(true) + allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) + expect(subject.get_version_from_properties('wordpress', true)).to eq({'name' => "alpha-222", 'code' => 1234}) + end + + it 'returns nil when alpha version name and code when not present' do + test_file_content = <<~CONTENT + jetpack.versionName=17.0 + jetpack.versionCode=123 + CONTENT + + allow(File).to receive(:exist?).and_return(true) + allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) + expect(subject.get_version_from_properties('jetpack', true)).to be_nil + end + end describe 'get_library_version_from_gradle_config' do it 'returns nil when gradle file is not present' do allow(File).to receive(:exists?).and_return(false) From 508ee83de94e3bab4d92279b8333b93d2303e67f Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 13 May 2021 13:03:01 -0500 Subject: [PATCH 17/57] address Danger issues --- .../actions/android/android_build_prechecks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb index 3478a25f2..9b768b432 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb @@ -9,7 +9,7 @@ def self.run(params) Fastlane::Helper::GitHelper.ensure_on_branch!('release') unless other_action.is_ci() - app = ENV['APP'].nil? ? params[:app]: ENV['APP'] + app = ENV['APP'].nil? ? params[:app] : ENV['APP'] message = '' beta_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) unless !params[:beta] && !params[:final] alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) if params[:alpha] From 3129d015ae510f7a071d84cc007ebf82e625c8c2 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 13 May 2021 13:07:15 -0500 Subject: [PATCH 18/57] address Danger issues --- spec/android_version_helper_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/android_version_helper_spec.rb b/spec/android_version_helper_spec.rb index acd2a73bf..cb17dd16d 100644 --- a/spec/android_version_helper_spec.rb +++ b/spec/android_version_helper_spec.rb @@ -8,11 +8,11 @@ wordpress.versionCode=123 wordpress.alpha.versionName=alpha-222 wordpress.alpha.versionCode=1234 - CONTENT + CONTENT allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_version_from_properties('wordpress', false)).to eq({'name' => "17.0", 'code' => 123}) + expect(subject.get_version_from_properties('wordpress', false)).to eq('name' => "17.0", 'code' => 123) end it 'returns alpha version name and code when present' do @@ -21,18 +21,18 @@ wordpress.versionCode=123 wordpress.alpha.versionName=alpha-222 wordpress.alpha.versionCode=1234 - CONTENT + CONTENT allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_version_from_properties('wordpress', true)).to eq({'name' => "alpha-222", 'code' => 1234}) + expect(subject.get_version_from_properties('wordpress', true)).to eq('name' => "alpha-222", 'code' => 1234) end it 'returns nil when alpha version name and code when not present' do test_file_content = <<~CONTENT jetpack.versionName=17.0 jetpack.versionCode=123 - CONTENT + CONTENT allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) From fd19dcab00c454960d78c9a426825460b35a7993 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 13 May 2021 13:08:27 -0500 Subject: [PATCH 19/57] address Danger issues --- spec/android_version_helper_spec.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/android_version_helper_spec.rb b/spec/android_version_helper_spec.rb index cb17dd16d..5948aed7e 100644 --- a/spec/android_version_helper_spec.rb +++ b/spec/android_version_helper_spec.rb @@ -12,7 +12,7 @@ allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_version_from_properties('wordpress', false)).to eq('name' => "17.0", 'code' => 123) + expect(subject.get_version_from_properties('wordpress', false)).to eq('name' => '17.0', 'code' => 123) end it 'returns alpha version name and code when present' do @@ -25,7 +25,7 @@ allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_version_from_properties('wordpress', true)).to eq('name' => "alpha-222", 'code' => 1234) + expect(subject.get_version_from_properties('wordpress', true)).to eq('name' => 'alpha-222', 'code' => 1234) end it 'returns nil when alpha version name and code when not present' do @@ -39,6 +39,7 @@ expect(subject.get_version_from_properties('jetpack', true)).to be_nil end end + describe 'get_library_version_from_gradle_config' do it 'returns nil when gradle file is not present' do allow(File).to receive(:exists?).and_return(false) From d1e095e937b0ea253661ba0ffcd91939289e0a47 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 13 May 2021 13:10:07 -0500 Subject: [PATCH 20/57] address Danger issues --- spec/android_version_helper_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/android_version_helper_spec.rb b/spec/android_version_helper_spec.rb index 5948aed7e..11ca2ae18 100644 --- a/spec/android_version_helper_spec.rb +++ b/spec/android_version_helper_spec.rb @@ -10,9 +10,9 @@ wordpress.alpha.versionCode=1234 CONTENT - allow(File).to receive(:exist?).and_return(true) - allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_version_from_properties('wordpress', false)).to eq('name' => '17.0', 'code' => 123) + allow(File).to receive(:exist?).and_return(true) + allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) + expect(subject.get_version_from_properties('wordpress', false)).to eq('name' => '17.0', 'code' => 123) end it 'returns alpha version name and code when present' do @@ -23,9 +23,9 @@ wordpress.alpha.versionCode=1234 CONTENT - allow(File).to receive(:exist?).and_return(true) - allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_version_from_properties('wordpress', true)).to eq('name' => 'alpha-222', 'code' => 1234) + allow(File).to receive(:exist?).and_return(true) + allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) + expect(subject.get_version_from_properties('wordpress', true)).to eq('name' => 'alpha-222', 'code' => 1234) end it 'returns nil when alpha version name and code when not present' do @@ -34,9 +34,9 @@ jetpack.versionCode=123 CONTENT - allow(File).to receive(:exist?).and_return(true) - allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_version_from_properties('jetpack', true)).to be_nil + allow(File).to receive(:exist?).and_return(true) + allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) + expect(subject.get_version_from_properties('jetpack', true)).to be_nil end end From 6f1da0f875dda3d99dc9e5f5828d453a541e1756 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 12:48:16 -0500 Subject: [PATCH 21/57] update app environemnt variable name and remove redudent instance variables --- .../android/android_betabuild_prechecks.rb | 19 +++--- .../android/android_build_prechecks.rb | 7 +-- .../android/android_bump_version_beta.rb | 40 +++++-------- .../android_bump_version_final_release.rb | 38 +++++------- .../android/android_bump_version_hotfix.rb | 37 +++++------- .../android/android_bump_version_release.rb | 59 +++++++------------ .../android/android_codefreeze_prechecks.rb | 7 +-- .../android_completecodefreeze_prechecks.rb | 7 +-- .../android_current_branch_is_hotfix.rb | 7 +-- .../android/android_finalize_prechecks.rb | 7 +-- .../android/android_get_alpha_version.rb | 7 +-- .../android/android_get_app_version.rb | 7 +-- .../android/android_get_release_version.rb | 7 +-- .../actions/android/android_tag_build.rb | 7 +-- 14 files changed, 100 insertions(+), 156 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb index 6518c29d5..687ecc211 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb @@ -11,13 +11,13 @@ def self.run(params) # Checkout develop and update Fastlane::Helper::GitHelper.checkout_and_pull('develop') - @app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] # Check versions - release_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) - message = "[#{@app}] The following current version has been detected: #{release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}\n" - alpha_release_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@app) - message << "[#{@app}] The following Alpha version has been detected: #{alpha_release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}\n" unless alpha_release_version.nil? + release_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + message = "[#{app}] The following current version has been detected: #{release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}\n" + alpha_release_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) + message << "[#{app}] The following Alpha version has been detected: #{alpha_release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}\n" unless alpha_release_version.nil? # Check branch app_version = Fastlane::Helper::Android::VersionHelper.get_public_version @@ -50,9 +50,9 @@ def self.run(params) end def self.get_user_build_version(version, message) - UI.user_error!("[#{@app}] Release branch for version #{version} doesn't exist. Abort.") unless Fastlane::Helper::GitHelper.checkout_and_pull(release: version) + UI.user_error!("[#{app}] Release branch for version #{version} doesn't exist. Abort.") unless Fastlane::Helper::GitHelper.checkout_and_pull(release: version) release_version = Fastlane::Helper::Android::VersionHelper.get_release_version - message << "#{@app}] Looking at branch release/#{version} as requested by user. Detected version: #{release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}.\n" + message << "#{app}] Looking at branch release/#{version} as requested by user. Detected version: #{release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}.\n" alpha_release_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version message << "and Alpha Version: #{alpha_release_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}\n" unless alpha_release_version.nil? [release_version, alpha_release_version] @@ -83,10 +83,9 @@ def self.available_options is_string: false, # true: verifies the input is a string, false: every kind of value default_value: false), # the default value if the user didn't provide one FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb index 9b768b432..b06663c5b 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb @@ -9,7 +9,7 @@ def self.run(params) Fastlane::Helper::GitHelper.ensure_on_branch!('release') unless other_action.is_ci() - app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] message = '' beta_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) unless !params[:beta] && !params[:final] alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) if params[:alpha] @@ -65,10 +65,9 @@ def self.available_options is_string: false, default_value: false), FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index a98c50200..58f3520ae 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -8,13 +8,22 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' Fastlane::Helper::GitHelper.ensure_on_branch!('release') - @app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] - create_config() - show_config() + current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) + new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_beta_version(current_version, current_version_alpha) + new_version_alpha = current_version_alpha.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(new_version_beta, current_version_alpha) + + vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME + vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE + UI.message("Current version[#{app}]: #{current_version[vname]}(#{current_version[vcode]})") + UI.message("Current alpha version[#{app}]: #{current_version_alpha[vname]}(#{current_version_alpha[vcode]})") unless current_version_alpha.nil? + UI.message("New beta version[#{app}]: #{new_version_beta[vname]}(#{new_version_beta[vcode]})") + UI.message("New alpha version[#{app}]: #{new_version_alpha[vname]}(#{new_version_alpha[vcode]})") unless current_version_alpha.nil? UI.message 'Updating build.gradle...' - Fastlane::Helper::Android::VersionHelper.update_versions(@app, @new_version_beta, @new_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(app, new_version_beta, new_version_alpha) UI.message 'Done!' Fastlane::Helper::Android::GitHelper.commit_version_bump() @@ -36,10 +45,9 @@ def self.available_options # Define all options your action supports. [ FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end @@ -56,24 +64,6 @@ def self.authors def self.is_supported?(platform) platform == :android end - - private - - def self.create_config - @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) - @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@app) - @new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_beta_version(@current_version, @current_version_alpha) - @new_version_alpha = @current_version_alpha.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(@new_version_beta, @current_version_alpha) - end - - def self.show_config - vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME - vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE - UI.message("Current version[#{@app}]: #{@current_version[vname]}(#{@current_version[vcode]})") - UI.message("Current alpha version[#{@app}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless @current_version_alpha.nil? - UI.message("New beta version[#{@app}]: #{@new_version_beta[vname]}(#{@new_version_beta[vcode]})") - UI.message("New alpha version[#{@app}]: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless @current_version_alpha.nil? - end end end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index a317baeb7..12165c871 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -8,12 +8,21 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' Fastlane::Helper::GitHelper.ensure_on_branch!('release') - @app = ENV['APP'].nil? ? params[:app] : ENV['APP'] - create_config() - show_config() + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] + + current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) + final_version = Fastlane::Helper::Android::VersionHelper.calc_final_release_version(current_version, current_version_alpha) + + + vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME + vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE + UI.message("Current version[#{app}]: #{current_version[vname]}(#{current_version[vcode]})") + UI.message("Current alpha version[#{app}]: #{current_version_alpha[vname]}(#{current_version_alpha[vcode]})") unless current_version_alpha.nil? + UI.message("New release version[#{app}]: #{final_version[vname]}(#{final_version[vcode]})") UI.message 'Updating version.properties...' - Fastlane::Helper::Android::VersionHelper.update_versions(@app, @final_version, @current_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(app, final_version, current_version_alpha) UI.message 'Done!' Fastlane::Helper::Android::GitHelper.commit_version_bump() @@ -35,10 +44,9 @@ def self.available_options # Define all options your action supports. [ FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end @@ -49,22 +57,6 @@ def self.authors def self.is_supported?(platform) platform == :android end - - private - - def self.create_config - @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) - @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@app) - @final_version = Fastlane::Helper::Android::VersionHelper.calc_final_release_version(@current_version, @current_version_alpha) - end - - def self.show_config - vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME - vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE - UI.message("Current version[#{@app}]: #{@current_version[vname]}(#{@current_version[vcode]})") - UI.message("Current alpha version[#{@app}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless @current_version_alpha.nil? - UI.message("New release version[#{@app}]: #{@final_version[vname]}(#{@final_version[vcode]})") - end end end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 329ad5097..76ec4ff2a 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -7,12 +7,20 @@ def self.run(params) require_relative '../../helper/android/android_git_helper.rb' Fastlane::Helper::GitHelper.create_branch("release/#{params[:version_name]}", from: params[:previous_version_name]) - @app = ENV['APP'].nil? ? params[:app] : ENV['APP'] - create_config(params[:previous_version_name], params[:version_name], params[:version_code]) - show_config() + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] + + current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) + new_version = Fastlane::Helper::Android::VersionHelper.calc_next_hotfix_version(params[:version_name], params[:version_code]) + new_short_version = new_version_name + new_release_branch = "release/#{new_short_version}" + + UI.message("Current version[#{app}]: #{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") + UI.message("New hotfix version[#{app}]: #{new_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{new_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") + UI.message("Release branch: #{new_release_branch}") UI.message 'Updating version.properties...' - Fastlane::Helper::Android::VersionHelper.update_versions(@app, @new_version, @current_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(app, new_version, current_version_alpha) UI.message 'Done!' Fastlane::Helper::Android::GitHelper.commit_version_bump() @@ -49,10 +57,9 @@ def self.available_options description: 'The version to branch from', is_string: true), # the default value if the user didn't provide one FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end @@ -63,22 +70,6 @@ def self.authors def self.is_supported?(platform) platform == :android end - - private - - def self.create_config(previous_version, new_version_name, new_version_code) - @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) - @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@app) - @new_version = Fastlane::Helper::Android::VersionHelper.calc_next_hotfix_version(new_version_name, new_version_code) - @new_short_version = new_version_name - @new_release_branch = "release/#{@new_short_version}" - end - - def self.show_config - UI.message("Current version[#{@app}]: #{@current_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{@current_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") - UI.message("New hotfix version[#{@app}]: #{@new_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{@new_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") - UI.message("Release branch: #{@new_release_branch}") - end end end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index ab97f5a28..065710cec 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -11,19 +11,31 @@ def self.run(params) other_action.ensure_git_branch(branch: 'develop') # Create new configuration - @app = ENV['APP'].nil? ? params[:app] : ENV['APP'] - @new_short_version = Fastlane::Helper::Android::VersionHelper.bump_version_release(@app) + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] + new_short_version = Fastlane::Helper::Android::VersionHelper.bump_version_release(app) - create_config() - show_config() + current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) + new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_release_version(current_version, current_version_alpha) + new_version_alpha = current_version_alpha.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(new_version_beta, current_version_alpha) + new_release_branch = "release/#{new_short_version}" + + vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME + vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE + UI.message("Current version[#{app}]: #{current_version[vname]}(#{current_version[vcode]})") + UI.message("Current alpha version[#{app}]: #{current_version_alpha[vname]}(#{current_version_alpha[vcode]})") unless current_version_alpha.nil? + UI.message("New beta version[#{app}]: #{new_version_beta[vname]}(#{new_version_beta[vcode]})") + UI.message("New alpha version[#{app}]: #{new_version_alpha[vname]}(#{new_version_alpha[vcode]})") unless current_version_alpha.nil? + UI.message("New version[#{app}]: #{new_short_version}") + UI.message("Release branch: #{new_release_branch}") # Update local develop and branch UI.message 'Creating new branch...' - Fastlane::Helper::GitHelper.create_branch(@new_release_branch, from: 'develop') + Fastlane::Helper::GitHelper.create_branch(new_release_branch, from: 'develop') UI.message 'Done!' UI.message 'Updating versions...' - Fastlane::Helper::Android::VersionHelper.update_versions(@app, @new_version_beta, @new_version_alpha) + Fastlane::Helper::Android::VersionHelper.update_versions(app, new_version_beta, new_version_alpha) Fastlane::Helper::Android::GitHelper.commit_version_bump() UI.message 'Done.' end @@ -44,10 +56,9 @@ def self.available_options # Define all options your action supports. [ FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end @@ -64,36 +75,6 @@ def self.authors def self.is_supported?(platform) platform == :android end - - private - - def self.create_config - @current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(@app) - @current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(@app) - @new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_release_version(@current_version, @current_version_alpha) - @new_version_alpha = @current_version_alpha.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(@new_version_beta, @current_version_alpha) - @new_release_branch = "release/#{@new_short_version}" - end - - def self.show_config - vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME - vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE - UI.message("Current version[#{@app}]: #{@current_version[vname]}(#{@current_version[vcode]})") - UI.message("Current alpha version[#{@app}]: #{@current_version_alpha[vname]}(#{@current_version_alpha[vcode]})") unless @current_version_alpha.nil? - UI.message("New beta version[#{@app}]: #{@new_version_beta[vname]}(#{@new_version_beta[vcode]})") - UI.message("New alpha version[#{@app}]: #{@new_version_alpha[vname]}(#{@new_version_alpha[vcode]})") unless @current_version_alpha.nil? - UI.message("New version[#{@app}]: #{@new_short_version}") - UI.message("Release branch: #{@new_release_branch}") - end - - def self.update_glotpress_key - dm_file = ENV['DOWNLOAD_METADATA'] - if File.exist?(dm_file) - sh("sed -i '' \"s/let glotPressWhatsNewKey.*/let glotPressWhatsNewKey = \\\"v#{@new_short_version}-whats-new\\\"/\" #{dm_file}") - else - UI.user_error!("Can't find #{dm_file}.") - end - end end end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb index 6247a996d..db08d81c0 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb @@ -14,7 +14,7 @@ def self.run(params) # Checkout develop and update Fastlane::Helper::GitHelper.checkout_and_pull('develop') - app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] # Create versions current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) @@ -61,10 +61,9 @@ def self.available_options is_string: false, # true: verifies the input is a string, false: every kind of value default_value: false), # the default value if the user didn't provide one FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb index 4745b3365..4d2595f55 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb @@ -9,7 +9,7 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') - app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] version = Fastlane::Helper::Android::VersionHelper.get_public_version(app) message = "Completing code freeze for: [#{app}]#{version}\n" @@ -45,10 +45,9 @@ def self.available_options is_string: false, # true: verifies the input is a string, false: every kind of value default_value: false), # the default value if the user didn't provide one FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb index a70f59423..821cfc418 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb @@ -7,7 +7,7 @@ module SharedValues class AndroidCurrentBranchIsHotfixAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] Fastlane::Helper::Android::VersionHelper.is_hotfix?(Fastlane::Helper::Android::VersionHelper.get_release_version(app)) end @@ -27,10 +27,9 @@ def self.available_options # Define all options your action supports. [ FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb index 1c5394aea..2a72d52b9 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb @@ -13,7 +13,7 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') - app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] version = Fastlane::Helper::Android::VersionHelper.get_public_version(app) message = "Finalizing release: #{version}\n" if !params[:skip_confirm] @@ -51,10 +51,9 @@ def self.available_options is_string: false, # true: verifies the input is a string, false: every kind of value default_value: false), # the default value if the user didn't provide one FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb index 2363a5098..9ecc64574 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb @@ -3,7 +3,7 @@ module Actions class AndroidGetAlphaVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) end @@ -23,10 +23,9 @@ def self.available_options # Define all options your action supports. [ FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb index 742a07846..753f61469 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb @@ -3,7 +3,7 @@ module Actions class AndroidGetAppVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] Fastlane::Helper::Android::VersionHelper.get_public_version(app) end @@ -23,10 +23,9 @@ def self.available_options # Define all options your action supports. [ FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index 0069c069d..927aab5ce 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -3,7 +3,7 @@ module Actions class AndroidGetReleaseVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper.rb' - app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] Fastlane::Helper::Android::VersionHelper.get_release_version(app) end @@ -23,10 +23,9 @@ def self.available_options # Define all options your action supports. [ FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb index 7cc16cbb5..84f326731 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb @@ -5,7 +5,7 @@ def self.run(params) require_relative '../../helper/android/android_version_helper.rb' require_relative '../../helper/android/android_git_helper.rb' - app = ENV['APP'].nil? ? params[:app] : ENV['APP'] + app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] release_ver = Fastlane::Helper::Android::VersionHelper.get_release_version(app) alpha_ver = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) @@ -33,10 +33,9 @@ def self.available_options is_string: false, default_value: true), FastlaneCore::ConfigItem.new(key: :app, - env_name: 'APP', + env_name: 'PROJECT_NAME', description: 'The app to get the release version for', - is_string: true, # true: verifies the input is a string, false: every kind of value - default_value: 'wordpress'), # the default value if the user didn't provide one + is_string: true), # true: verifies the input is a string, false: every kind of value ] end From 13a61adc1b14402e1dcde4ae980ea6d2b7057e7d Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 13:50:16 -0400 Subject: [PATCH 22/57] Update lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb Co-authored-by: Olivier Halligon --- .../wpmreleasetoolkit/helper/android/android_version_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index ee34648c2..abaf7d06d 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -50,7 +50,7 @@ def self.get_release_version(app) # # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # - def self.get_version_from_properties(product_name, is_alpha) + def self.get_version_from_properties(product_name:, is_alpha: false) version_name_key = "#{product_name}.#{is_alpha ? 'alpha.' : ''}versionName" version_code_key = "#{product_name}.#{is_alpha ? 'alpha.' : ''}versionCode" From ba2adf6bcbfbd9df0587bfb520896739170eec36 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 12:54:04 -0500 Subject: [PATCH 23/57] used named parameters for callsites for get_version_from-properties --- .../helper/android/android_version_helper.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index abaf7d06d..187232db9 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -31,7 +31,7 @@ module VersionHelper # - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number # def self.get_public_version(app) - version = get_version_from_properties(app, false) + version = get_version_from_properties(product_name: app) vp = get_version_parts(version[VERSION_NAME]) return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" unless is_hotfix?(version) @@ -43,7 +43,7 @@ def self.get_public_version(app) # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # def self.get_release_version(app) - return get_version_from_properties(app, false) + return get_version_from_properties(product_name: app) end # Extract the version name and code from the `version.properties` file in the project root @@ -77,7 +77,7 @@ def self.get_version_from_properties(product_name:, is_alpha: false) # or `nil` if `$HAS_ALPHA_VERSION` is not defined. # def self.get_alpha_version(app) - return get_version_from_properties(app, true) + return get_version_from_properties(product_name: app, is_alpha: true) end # Determines if a version name corresponds to an alpha version (starts with `"alpha-"`` prefix) @@ -279,7 +279,7 @@ def self.bump_version_release(app) # def self.bump_version_for_app(app, is_alpha) # Bump release - current_version = get_version_from_properties(app, is_alpha) + current_version = get_version_from_properties(product_name: app, is_alpha: is_alpha) UI.message("Current version: #{current_version[VERSION_NAME]}") new_version = calc_next_release_base_version(current_version) UI.message("New version: #{new_version[VERSION_NAME]}") From 3c13d353f2301060128f4daa90016c5105a2186a Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 12:57:08 -0500 Subject: [PATCH 24/57] update app env var description --- .../actions/android/android_betabuild_prechecks.rb | 2 +- .../actions/android/android_build_prechecks.rb | 2 +- .../actions/android/android_bump_version_beta.rb | 2 +- .../actions/android/android_bump_version_final_release.rb | 2 +- .../actions/android/android_bump_version_hotfix.rb | 2 +- .../actions/android/android_bump_version_release.rb | 2 +- .../actions/android/android_codefreeze_prechecks.rb | 2 +- .../actions/android/android_completecodefreeze_prechecks.rb | 2 +- .../actions/android/android_current_branch_is_hotfix.rb | 2 +- .../actions/android/android_finalize_prechecks.rb | 2 +- .../actions/android/android_get_alpha_version.rb | 2 +- .../actions/android/android_get_app_version.rb | 2 +- .../actions/android/android_get_release_version.rb | 2 +- .../wpmreleasetoolkit/actions/android/android_tag_build.rb | 2 +- 14 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb index 687ecc211..d7097693c 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb @@ -84,7 +84,7 @@ def self.available_options default_value: false), # the default value if the user didn't provide one FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb index b06663c5b..d2cf31184 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb @@ -66,7 +66,7 @@ def self.available_options default_value: false), FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index 58f3520ae..3ff9eb4e4 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -46,7 +46,7 @@ def self.available_options [ FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index 12165c871..1765fb5fb 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -45,7 +45,7 @@ def self.available_options [ FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 76ec4ff2a..2ab6bc515 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -58,7 +58,7 @@ def self.available_options is_string: true), # the default value if the user didn't provide one FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index 065710cec..57a8ef1cb 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -57,7 +57,7 @@ def self.available_options [ FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb index db08d81c0..a6eae8dbe 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb @@ -62,7 +62,7 @@ def self.available_options default_value: false), # the default value if the user didn't provide one FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb index 4d2595f55..fdf6e18fa 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb @@ -46,7 +46,7 @@ def self.available_options default_value: false), # the default value if the user didn't provide one FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb index 821cfc418..5473d1b3f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb @@ -28,7 +28,7 @@ def self.available_options [ FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb index 2a72d52b9..731a65a72 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb @@ -52,7 +52,7 @@ def self.available_options default_value: false), # the default value if the user didn't provide one FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb index 9ecc64574..1310677ef 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb @@ -24,7 +24,7 @@ def self.available_options [ FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'TThe name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb index 753f61469..0cfa4b361 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb @@ -24,7 +24,7 @@ def self.available_options [ FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index 927aab5ce..487016f66 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -24,7 +24,7 @@ def self.available_options [ FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb index 84f326731..963f60bba 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb @@ -34,7 +34,7 @@ def self.available_options default_value: true), FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'The app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end From b58fb59582ac041cfccfd9d1e9d28834f023f7e3 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 13:44:30 -0500 Subject: [PATCH 25/57] introduce has_version_properties env variable to allow version properies to not break clients --- .../helper/android/android_git_helper.rb | 18 ++++++--- .../helper/android/android_version_helper.rb | 37 +++++++++++++------ 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb index be1d0c45c..8f8b353e6 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb @@ -12,11 +12,19 @@ module GitHelper # @env PROJECT_NAME The name of the directory containing the project code (especially containing the `build.gradle` file) # def self.commit_version_bump - Fastlane::Helper::GitHelper.commit( - message: 'Bump version number', - files: File.join(ENV['PROJECT_ROOT_FOLDER'], 'version.properties'), - push: true - ) + if ENV['HAS_VERSION_PROPERTIES'].nil? + Fastlane::Helper::GitHelper.commit( + message: 'Bump version number', + files: File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'build.gradle'), + push: true + ) + else + Fastlane::Helper::GitHelper.commit( + message: 'Bump version number', + files: File.join(ENV['PROJECT_ROOT_FOLDER'], 'version.properties'), + push: true + ) + end end # Calls the `tools/update-translations.sh` script from the project repo, then lint them using the provided gradle task diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 187232db9..3edcb7b4b 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -31,7 +31,7 @@ module VersionHelper # - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number # def self.get_public_version(app) - version = get_version_from_properties(product_name: app) + version = get_release_version(product_name: app) vp = get_version_parts(version[VERSION_NAME]) return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" unless is_hotfix?(version) @@ -43,6 +43,14 @@ def self.get_public_version(app) # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # def self.get_release_version(app) + if ENV['HAS_VERSION_PROPERTIES'].nil? + section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {' + gradle_path = self.gradle_path + name = get_version_name_from_gradle_file(gradle_path, section) + code = get_version_build_from_gradle_file(gradle_path, section) + return { VERSION_NAME => name, VERSION_CODE => code } + end + return get_version_from_properties(product_name: app) end @@ -77,6 +85,15 @@ def self.get_version_from_properties(product_name:, is_alpha: false) # or `nil` if `$HAS_ALPHA_VERSION` is not defined. # def self.get_alpha_version(app) + if ENV['HAS_VERSION_PROPERTIES'].nil? + return nil if ENV['HAS_ALPHA_VERSION'].nil? + + section = 'defaultConfig' + gradle_path = self.gradle_path + name = get_version_name_from_gradle_file(gradle_path, section) + code = get_version_build_from_gradle_file(gradle_path, section) + return { VERSION_NAME => name, VERSION_CODE => code } + end return get_version_from_properties(product_name: app, is_alpha: true) end @@ -270,16 +287,7 @@ def self.is_hotfix?(version) # def self.bump_version_release(app) # Bump release - return bump_version_for_app(app, false) - end - - # Prints the current and next version names for a given section to stdout, then returns the next version - # - # @return [String] The next version name to use after bumping the currently used version. - # - def self.bump_version_for_app(app, is_alpha) - # Bump release - current_version = get_version_from_properties(product_name: app, is_alpha: is_alpha) + current_version = get_release_version(app) UI.message("Current version: #{current_version[VERSION_NAME]}") new_version = calc_next_release_base_version(current_version) UI.message("New version: #{new_version[VERSION_NAME]}") @@ -294,6 +302,13 @@ def self.bump_version_for_app(app, is_alpha) # @param [Hash] new_version_alpha The version hash for the alpha , containing values for keys "name" and "code" # def self.update_versions(app, new_version_beta, new_version_alpha) + + if ENV['HAS_VERSION_PROPERTIES'].nil? + self.update_version(new_version_beta, ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {') + self.update_version(new_version_alpha, 'defaultConfig') unless new_version_alpha.nil? + return + end + new_version_name_beta_key = "#{app}.versionName" new_version_code_beta_key = "#{app}.versionCode" new_version_name_alpha_key = "#{app}.alpha.versionName" From 47988cd35f1fb4a99b0469128fa153d44aab7d6f Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 13:50:39 -0500 Subject: [PATCH 26/57] include removed functions for accessing version form build.gradle --- .../helper/android/android_version_helper.rb | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 3edcb7b4b..56bdd505d 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -404,6 +404,116 @@ def self.verify_version(version) def self.is_int? string true if Integer(string) rescue false end + + + ######### + # Functions to support versioning through build.gradle - can be removed once all projects adopt version.properties + ######## + + # Extract the versionName from a build.gradle file + # + # @param [String] file_path The path to the `.gradle` file + # @param [String] section The name of the section we expect the keyword to be in, e.g. "defaultConfig" or "vanilla" + # + # @return [String] The value of the versionName attribute as found in the build.gradle file and for this section. + # + def self.get_version_name_from_gradle_file(file_path, section) + res = get_keyword_from_gradle_file(file_path, section, 'versionName') + res = res.tr('\"', '') unless res.nil? + return res + end + + # Extract the versionCode rom a build.gradle file + # + # @param [String] file_path The path to the `.gradle` file + # @param [String] section The name of the section we expect the keyword to be in, e.g. "defaultConfig" or "vanilla" + # + # @return [String] The value of the versionCode attribute as found in the build.gradle file and for this section. + # + def self.get_version_build_from_gradle_file(file_path, section) + res = get_keyword_from_gradle_file(file_path, section, 'versionCode') + return res.to_i + end + + # Extract the value for a specific keyword in a specific section of a `.gradle` file + # + # @todo: This implementation is very fragile. This should be done parsing the file in a proper way. + # Leveraging gradle itself is probably the easiest way. + # + # @param [String] file_path The path of the `.gradle` file to extract the value from + # @param [String] section The name of the section from which we want to extract this keyword from. For example `defaultConfig` or `myFlavor` + # @param [String] keyword The keyword (key name) we want the value for + # + # @return [String] Returns the value for that keyword in the section of the `.gradle` file, or nil if not found. + # + def self.get_keyword_from_gradle_file(file_path, section, keyword) + found_section = false + File.open(file_path, 'r') do |file| + file.each_line do |line| + if !found_section + found_section = true if line.include?(section) + else + return line.split(' ')[1] if line.include?(keyword) && !line.include?("\"#{keyword}\"") && !line.include?("P#{keyword}") + end + end + end + return nil + end + # The path to the build.gradle file for the project. + # + # @env PROJECT_ROOT_FOLDER The path to the root of the project (the folder containing the `.git` directory). + # @env PROJECT_NAME The name of the project, i.e. the name of the subdirectory containing the project's `build.gradle` file. + # + # @return [String] The path of the `build.gradle` file inside the project subfolder in the project's repo + # + def self.gradle_path + UI.user_error!("You need to set the \`PROJECT_ROOT_FOLDER\` environment variable to the path to the project's root") if ENV['PROJECT_ROOT_FOLDER'].nil? + UI.user_error!("You need to set the \`PROJECT_NAME\` environment variable to the relative path to the project subfolder name") if ENV['PROJECT_NAME'].nil? + File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'build.gradle') + end + + # Update both the versionName and versionCode of the build.gradle file to the specified version. + # + # @param [Hash] version The version hash, containing values for keys "name" and "code" + # @param [String] section The name of the section to update in the build.gradle file, e.g. "defaultConfig" or "vanilla" + # + # @todo This implementation is very fragile. This should be done parsing the file in a proper way. + # Leveraging gradle itself is probably the easiest way. + # + def self.update_version(version, section) + gradle_path = self.gradle_path + temp_file = Tempfile.new('fastlaneIncrementVersion') + found_section = false + version_updated = 0 + File.open(gradle_path, 'r') do |file| + file.each_line do |line| + if !found_section + temp_file.puts line + found_section = true if line.include? section + else + if version_updated < 2 + if line.include?('versionName') && !line.include?('"versionName"') && !line.include?('PversionName') + version_name = line.split(' ')[1].tr('\"', '') + line.sub!(version_name, version[VERSION_NAME].to_s) + version_updated = version_updated + 1 + end + + if line.include? 'versionCode' + version_code = line.split(' ')[1] + line.sub!(version_code, version[VERSION_CODE].to_s) + version_updated = version_updated + 1 + end + end + temp_file.puts line + end + end + file.close + end + temp_file.rewind + temp_file.close + FileUtils.mv(temp_file.path, gradle_path) + temp_file.unlink + end end end end From 795210a9f6909a6390a9e4be51b534af61959632 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 14:20:29 -0500 Subject: [PATCH 27/57] check for properties file existence instead of using environment variable --- .../helper/android/android_version_helper.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 4840beb72..65695eceb 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -43,7 +43,7 @@ def self.get_public_version(app) # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # def self.get_release_version(app) - if ENV['HAS_VERSION_PROPERTIES'].nil? + if properties_file_exists section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {' gradle_path = self.gradle_path name = get_version_name_from_gradle_file(gradle_path, section) @@ -54,6 +54,12 @@ def self.get_release_version(app) return get_version_from_properties(product_name: app) end + def self.properties_file_exists + properties_file_path = File.join(ENV['PROJECT_ROOT_FOLDER'] || '.', 'version.properties') + + return File.exist?(properties_file_path) + end + # Extract the version name and code from the `version.properties` file in the project root # # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively @@ -85,7 +91,7 @@ def self.get_version_from_properties(product_name:, is_alpha: false) # or `nil` if `$HAS_ALPHA_VERSION` is not defined. # def self.get_alpha_version(app) - if ENV['HAS_VERSION_PROPERTIES'].nil? + if properties_file_exists return nil if ENV['HAS_ALPHA_VERSION'].nil? section = 'defaultConfig' @@ -303,7 +309,7 @@ def self.bump_version_release(app) # def self.update_versions(app, new_version_beta, new_version_alpha) - if ENV['HAS_VERSION_PROPERTIES'].nil? + if properties_file_exists self.update_version(new_version_beta, ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {') self.update_version(new_version_alpha, 'defaultConfig') unless new_version_alpha.nil? return From 842dec004fd4cb1ba817fb542ebb91fa317c1abf Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 14:23:49 -0500 Subject: [PATCH 28/57] address lint issues --- .../actions/android/android_build_prechecks.rb | 4 ++-- .../actions/android/android_bump_version_final_release.rb | 1 - .../actions/android/android_current_branch_is_hotfix.rb | 2 +- .../actions/android/android_get_alpha_version.rb | 2 +- .../actions/android/android_get_app_version.rb | 2 +- .../actions/android/android_get_release_version.rb | 2 +- .../helper/android/android_version_helper.rb | 2 -- 7 files changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb index 3710ee54c..4da790f47 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb @@ -2,8 +2,8 @@ module Fastlane module Actions class AndroidBuildPrechecksAction < Action def self.run(params) - require_relative '../../helper/android/android_version_helper.rb' - require_relative '../../helper/git_helper.rb' + require_relative '../../helper/android/android_version_helper' + require_relative '../../helper/git_helper' UI.user_error!("Can't build beta and final at the same time!") if params[:final] && params[:beta] diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index 508fb05c3..76c70c0c9 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -14,7 +14,6 @@ def self.run(params) current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) final_version = Fastlane::Helper::Android::VersionHelper.calc_final_release_version(current_version, current_version_alpha) - vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE UI.message("Current version[#{app}]: #{current_version[vname]}(#{current_version[vcode]})") diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb index 5473d1b3f..60d511521 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb @@ -6,7 +6,7 @@ module SharedValues class AndroidCurrentBranchIsHotfixAction < Action def self.run(params) - require_relative '../../helper/android/android_version_helper.rb' + require_relative '../../helper/android/android_version_helper' app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] Fastlane::Helper::Android::VersionHelper.is_hotfix?(Fastlane::Helper::Android::VersionHelper.get_release_version(app)) end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb index 1310677ef..997a00184 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb @@ -2,7 +2,7 @@ module Fastlane module Actions class AndroidGetAlphaVersionAction < Action def self.run(params) - require_relative '../../helper/android/android_version_helper.rb' + require_relative '../../helper/android/android_version_helper' app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb index 0cfa4b361..193e59c40 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb @@ -2,7 +2,7 @@ module Fastlane module Actions class AndroidGetAppVersionAction < Action def self.run(params) - require_relative '../../helper/android/android_version_helper.rb' + require_relative '../../helper/android/android_version_helper' app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] Fastlane::Helper::Android::VersionHelper.get_public_version(app) end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index 487016f66..ae815821e 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -2,7 +2,7 @@ module Fastlane module Actions class AndroidGetReleaseVersionAction < Action def self.run(params) - require_relative '../../helper/android/android_version_helper.rb' + require_relative '../../helper/android/android_version_helper' app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] Fastlane::Helper::Android::VersionHelper.get_release_version(app) end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 65695eceb..d3a885866 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -308,7 +308,6 @@ def self.bump_version_release(app) # @param [Hash] new_version_alpha The version hash for the alpha , containing values for keys "name" and "code" # def self.update_versions(app, new_version_beta, new_version_alpha) - if properties_file_exists self.update_version(new_version_beta, ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {') self.update_version(new_version_alpha, 'defaultConfig') unless new_version_alpha.nil? @@ -411,7 +410,6 @@ def self.is_int? string true if Integer(string) rescue false end - ######### # Functions to support versioning through build.gradle - can be removed once all projects adopt version.properties ######## From 458f202dbfea2f62a7727e5379600ca0bbc7d59b Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 15:07:06 -0500 Subject: [PATCH 29/57] update Changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b7af5e3c..258d90ff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,11 +10,11 @@ _None_ ### New Features -_None_ +* Support for a version.properties to manage app versioning - all existing paths remain intact and new paths are only used when a version.properties file is present ### Bug Fixes -_None_ +* Some cleanup to how we scope variables in some of our actions ### Internal Changes From 04c674b6340546c412124736a9263fd9342c9824 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 15:09:03 -0500 Subject: [PATCH 30/57] add named parameters to tests --- spec/android_version_helper_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/android_version_helper_spec.rb b/spec/android_version_helper_spec.rb index a9fce9d4d..814d5d1f7 100644 --- a/spec/android_version_helper_spec.rb +++ b/spec/android_version_helper_spec.rb @@ -12,7 +12,7 @@ allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_version_from_properties('wordpress', false)).to eq('name' => '17.0', 'code' => 123) + expect(subject.get_version_from_properties(product_name: 'wordpress')).to eq('name' => '17.0', 'code' => 123) end it 'returns alpha version name and code when present' do @@ -25,7 +25,7 @@ allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_version_from_properties('wordpress', true)).to eq('name' => 'alpha-222', 'code' => 1234) + expect(subject.get_version_from_properties(product_name: 'wordpress', is_alpha: true)).to eq('name' => 'alpha-222', 'code' => 1234) end it 'returns nil when alpha version name and code when not present' do @@ -36,7 +36,7 @@ allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_version_from_properties('jetpack', true)).to be_nil + expect(subject.get_version_from_properties(product_name: 'jetpack', is_alpha_version: true)).to be_nil end end From d10336d06b964cf403e1327fbb5d9e43d6a6593f Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 15:24:33 -0500 Subject: [PATCH 31/57] fix keyed named parameter in test --- spec/android_version_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/android_version_helper_spec.rb b/spec/android_version_helper_spec.rb index 814d5d1f7..179c82b41 100644 --- a/spec/android_version_helper_spec.rb +++ b/spec/android_version_helper_spec.rb @@ -36,7 +36,7 @@ allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_version_from_properties(product_name: 'jetpack', is_alpha_version: true)).to be_nil + expect(subject.get_version_from_properties(product_name: 'jetpack', is_alpha: true)).to be_nil end end From a6856be820731fdaf47487cfe5c682893e3f9a13 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 16:31:25 -0500 Subject: [PATCH 32/57] address lint issues --- .../wpmreleasetoolkit/helper/android/android_version_helper.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index d3a885866..fa05f6ebe 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -463,6 +463,7 @@ def self.get_keyword_from_gradle_file(file_path, section, keyword) end return nil end + # The path to the build.gradle file for the project. # # @env PROJECT_ROOT_FOLDER The path to the root of the project (the folder containing the `.git` directory). From f638e5fa445bf1e4e1f6cefc66340a505a5cfa7d Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Thu, 10 Jun 2021 16:33:24 -0500 Subject: [PATCH 33/57] address lint issues --- .../wpmreleasetoolkit/helper/android/android_version_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index fa05f6ebe..c9daa2ab6 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -463,7 +463,7 @@ def self.get_keyword_from_gradle_file(file_path, section, keyword) end return nil end - + # The path to the build.gradle file for the project. # # @env PROJECT_ROOT_FOLDER The path to the root of the project (the folder containing the `.git` directory). From 4b2bd1bfef9dce09288cbc2321d6032c696fe9f5 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Fri, 11 Jun 2021 17:17:08 -0400 Subject: [PATCH 34/57] Update spec/android_version_helper_spec.rb Co-authored-by: Olivier Halligon --- spec/android_version_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/android_version_helper_spec.rb b/spec/android_version_helper_spec.rb index 179c82b41..614c8fd8f 100644 --- a/spec/android_version_helper_spec.rb +++ b/spec/android_version_helper_spec.rb @@ -28,7 +28,7 @@ expect(subject.get_version_from_properties(product_name: 'wordpress', is_alpha: true)).to eq('name' => 'alpha-222', 'code' => 1234) end - it 'returns nil when alpha version name and code when not present' do + it 'returns nil when alpha version name and code not present' do test_file_content = <<~CONTENT jetpack.versionName=17.0 jetpack.versionCode=123 From f67123c6251f5c611b2733cbb4f9d962fd8a342a Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Fri, 11 Jun 2021 17:17:31 -0400 Subject: [PATCH 35/57] Update CHANGELOG.md Co-authored-by: Olivier Halligon --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 258d90ff5..37f166bfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ _None_ ### New Features * Support for a version.properties to manage app versioning - all existing paths remain intact and new paths are only used when a version.properties file is present - +* Add support for providing an `app:` parameter to most versioning-related actions to allow support for multiple apps hosted in a monorepo ### Bug Fixes * Some cleanup to how we scope variables in some of our actions From 35503535d8cf9283351ad67f5450c63c2c8bbf7f Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Fri, 11 Jun 2021 17:17:46 -0400 Subject: [PATCH 36/57] Update lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb Co-authored-by: Olivier Halligon --- .../actions/android/android_betabuild_prechecks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb index b23859e71..53733e2ec 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb @@ -11,7 +11,7 @@ def self.run(params) # Checkout develop and update Fastlane::Helper::GitHelper.checkout_and_pull('develop') - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] + app = params[:app] # Check versions release_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) From 5c3c6d887409333e3164513c9e1ab8f4d3c1c64c Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Fri, 11 Jun 2021 17:18:09 -0400 Subject: [PATCH 37/57] Update lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb Co-authored-by: Olivier Halligon --- .../actions/android/android_build_prechecks.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb index 4da790f47..37aaf6d73 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb @@ -9,7 +9,7 @@ def self.run(params) Fastlane::Helper::GitHelper.ensure_on_branch!('release') unless other_action.is_ci() - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] + app = params[:app] message = '' beta_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) unless !params[:beta] && !params[:final] alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) if params[:alpha] From 74e0bc9e90b0df4d26b03a32e557cbe6e3776e4f Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Fri, 11 Jun 2021 17:18:18 -0400 Subject: [PATCH 38/57] Update lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb Co-authored-by: Olivier Halligon --- .../actions/android/android_current_branch_is_hotfix.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb index 60d511521..03d593dcb 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb @@ -7,8 +7,8 @@ module SharedValues class AndroidCurrentBranchIsHotfixAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper' - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] - Fastlane::Helper::Android::VersionHelper.is_hotfix?(Fastlane::Helper::Android::VersionHelper.get_release_version(app)) + version = Fastlane::Helper::Android::VersionHelper.get_release_version(params[:app]) + Fastlane::Helper::Android::VersionHelper.is_hotfix?(version) end ##################################################### From 66c6a7b9049d5d4afdb1b7ed9f5e5a50ac9594ee Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Mon, 14 Jun 2021 14:53:32 -0500 Subject: [PATCH 39/57] fix error in inverted properties --- .../helper/android/android_version_helper.rb | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index c9daa2ab6..4a416030d 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -92,15 +92,16 @@ def self.get_version_from_properties(product_name:, is_alpha: false) # def self.get_alpha_version(app) if properties_file_exists - return nil if ENV['HAS_ALPHA_VERSION'].nil? - - section = 'defaultConfig' - gradle_path = self.gradle_path - name = get_version_name_from_gradle_file(gradle_path, section) - code = get_version_build_from_gradle_file(gradle_path, section) - return { VERSION_NAME => name, VERSION_CODE => code } + return get_version_from_properties(product_name: app, is_alpha: true) end - return get_version_from_properties(product_name: app, is_alpha: true) + + return nil if ENV['HAS_ALPHA_VERSION'].nil? + + section = 'defaultConfig' + gradle_path = self.gradle_path + name = get_version_name_from_gradle_file(gradle_path, section) + code = get_version_build_from_gradle_file(gradle_path, section) + return { VERSION_NAME => name, VERSION_CODE => code } end # Determines if a version name corresponds to an alpha version (starts with `"alpha-"`` prefix) @@ -309,19 +310,19 @@ def self.bump_version_release(app) # def self.update_versions(app, new_version_beta, new_version_alpha) if properties_file_exists - self.update_version(new_version_beta, ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {') - self.update_version(new_version_alpha, 'defaultConfig') unless new_version_alpha.nil? + new_version_name_beta_key = "#{app}.versionName" + new_version_code_beta_key = "#{app}.versionCode" + new_version_name_alpha_key = "#{app}.alpha.versionName" + new_version_code_alpha_key = "#{app}.alpha.versionCode" + Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_name_beta_key}", "-Pvalue=#{new_version_beta[VERSION_NAME]}") + Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_code_beta_key}", "-Pvalue=#{new_version_beta[VERSION_CODE]}") + Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_name_alpha_key}", "-Pvalue=#{new_version_alpha[VERSION_NAME]}") unless new_version_alpha.nil? + Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_code_alpha_key}", "-Pvalue=#{new_version_alpha[VERSION_CODE]}") unless new_version_alpha.nil? return end - new_version_name_beta_key = "#{app}.versionName" - new_version_code_beta_key = "#{app}.versionCode" - new_version_name_alpha_key = "#{app}.alpha.versionName" - new_version_code_alpha_key = "#{app}.alpha.versionCode" - Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_name_beta_key}", "-Pvalue=#{new_version_beta[VERSION_NAME]}") - Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_code_beta_key}", "-Pvalue=#{new_version_beta[VERSION_CODE]}") - Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_name_alpha_key}", "-Pvalue=#{new_version_alpha[VERSION_NAME]}") unless new_version_alpha.nil? - Action.sh('./gradlew', 'updateVersionProperties', "-Pkey=#{new_version_code_alpha_key}", "-Pvalue=#{new_version_alpha[VERSION_CODE]}") unless new_version_alpha.nil? + self.update_version(new_version_beta, ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {') + self.update_version(new_version_alpha, 'defaultConfig') unless new_version_alpha.nil? end # Compute the name of the previous hotfix version. From b5465bf5e4da1855dcfae8fba847216149dcb75a Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Mon, 14 Jun 2021 16:04:14 -0500 Subject: [PATCH 40/57] address missing docstrings --- .../helper/android/android_version_helper.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 4a416030d..577ed3a5c 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -26,6 +26,8 @@ module VersionHelper # "1.2" # Assuming build.gradle contains versionName "1.2.0" # "1.2.3" # Assuming build.gradle contains versionName "1.2.3" # + # @param [String] app The name of the app to be used for beta and alpha version update + # # @return [String] The public-facing version number, extracted from the `versionName` of the `build.gradle` file. # - If this version is a hotfix (more than 2 parts and 3rd part is non-zero), returns the "X.Y.Z" formatted string # - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number @@ -40,6 +42,8 @@ def self.get_public_version(app) # Extract the version name and code from the release version of the app from `version.properties file` # + # @param [String] app The name of the app to be used for beta and alpha version update + # # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # def self.get_release_version(app) @@ -62,6 +66,9 @@ def self.properties_file_exists # Extract the version name and code from the `version.properties` file in the project root # + # @param [String] product_name The name of the app to extract the version from e.g. wordpress, simplenote + # @param [Boolean] is_alpha true if the alpha version should be returned, false otherwise + # # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # def self.get_version_from_properties(product_name:, is_alpha: false) @@ -87,6 +94,8 @@ def self.get_version_from_properties(product_name:, is_alpha: false) # Extract the version name and code from the `version.properties` file in the project root # + # @param [String] app The name of the app to be used for beta and alpha version update + # # @return [Hash] A hash with 2 keys `"name"` and `"code"` containing the extracted version name and code, respectively, # or `nil` if `$HAS_ALPHA_VERSION` is not defined. # @@ -290,6 +299,7 @@ def self.is_hotfix?(version) # Prints the current and next release version names to stdout, then returns the next release version # + # @param [String] app The name of the app to be used for beta and alpha version update # @return [String] The next release version name to use after bumping the currently used release version. # def self.bump_version_release(app) @@ -305,6 +315,7 @@ def self.bump_version_release(app) # Update the `version.properties` file with new `versionName` and `versionCode` values # + # @param [String] app The name of the app to be used for beta and alpha version update # @param [Hash] new_version_beta The version hash for the beta, containing values for keys "name" and "code" # @param [Hash] new_version_alpha The version hash for the alpha , containing values for keys "name" and "code" # From b93165f446bbec773e04565ca83a8de222d0e7f4 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Mon, 14 Jun 2021 18:10:48 -0500 Subject: [PATCH 41/57] fix inverted properties file check --- .../helper/android/android_version_helper.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 577ed3a5c..3b0faf518 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -48,14 +48,15 @@ def self.get_public_version(app) # def self.get_release_version(app) if properties_file_exists - section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {' - gradle_path = self.gradle_path - name = get_version_name_from_gradle_file(gradle_path, section) - code = get_version_build_from_gradle_file(gradle_path, section) - return { VERSION_NAME => name, VERSION_CODE => code } + return get_version_from_properties(product_name: app) end - return get_version_from_properties(product_name: app) + section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {' + gradle_path = self.gradle_path + name = get_version_name_from_gradle_file(gradle_path, section) + code = get_version_build_from_gradle_file(gradle_path, section) + return { VERSION_NAME => name, VERSION_CODE => code } + end def self.properties_file_exists From 10c27c6020ac95baba62043cd1cbe838650b062d Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Mon, 14 Jun 2021 18:36:38 -0500 Subject: [PATCH 42/57] use param dict for get_release_version --- .../actions/android/android_get_release_version.rb | 2 +- .../wpmreleasetoolkit/helper/android/android_version_helper.rb | 1 - spec/android_version_helper_spec.rb | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index ae815821e..c5b98c29a 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -4,7 +4,7 @@ class AndroidGetReleaseVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper' app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] - Fastlane::Helper::Android::VersionHelper.get_release_version(app) + Fastlane::Helper::Android::VersionHelper.get_release_version(params[:app]) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 3b0faf518..4319dda72 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -56,7 +56,6 @@ def self.get_release_version(app) name = get_version_name_from_gradle_file(gradle_path, section) code = get_version_build_from_gradle_file(gradle_path, section) return { VERSION_NAME => name, VERSION_CODE => code } - end def self.properties_file_exists diff --git a/spec/android_version_helper_spec.rb b/spec/android_version_helper_spec.rb index 614c8fd8f..62ee92249 100644 --- a/spec/android_version_helper_spec.rb +++ b/spec/android_version_helper_spec.rb @@ -36,7 +36,7 @@ allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_version_from_properties(product_name: 'jetpack', is_alpha: true)).to be_nil + expect(subject.get_release_version('jetpack')).to eq('name' => '17.0', 'code' => 123) end end From b1f5d1e1d4a7f2299a891110688aed61b3c00c58 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Mon, 14 Jun 2021 18:37:24 -0500 Subject: [PATCH 43/57] revert to original spec --- spec/android_version_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/android_version_helper_spec.rb b/spec/android_version_helper_spec.rb index 62ee92249..614c8fd8f 100644 --- a/spec/android_version_helper_spec.rb +++ b/spec/android_version_helper_spec.rb @@ -36,7 +36,7 @@ allow(File).to receive(:exist?).and_return(true) allow(File).to receive(:open).with('./version.properties', 'r').and_yield(StringIO.new(test_file_content)) - expect(subject.get_release_version('jetpack')).to eq('name' => '17.0', 'code' => 123) + expect(subject.get_version_from_properties(product_name: 'jetpack', is_alpha: true)).to be_nil end end From cb939d6f00ed0483eb4baf107361b7281bf9feac Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Mon, 14 Jun 2021 18:39:00 -0500 Subject: [PATCH 44/57] revert use of param dict in get release version --- .../actions/android/android_get_release_version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index c5b98c29a..ae815821e 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -4,7 +4,7 @@ class AndroidGetReleaseVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper' app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] - Fastlane::Helper::Android::VersionHelper.get_release_version(params[:app]) + Fastlane::Helper::Android::VersionHelper.get_release_version(app) end ##################################################### From 72efa63c4baf47a1225e7e46937d80fdfb88b4b1 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Tue, 15 Jun 2021 09:43:04 -0500 Subject: [PATCH 45/57] address unnecessary params check --- CHANGELOG.md | 1 + .../actions/android/android_bump_version_beta.rb | 2 +- .../actions/android/android_bump_version_final_release.rb | 2 +- .../actions/android/android_bump_version_release.rb | 2 +- .../actions/android/android_codefreeze_prechecks.rb | 2 +- .../android/android_completecodefreeze_prechecks.rb | 2 +- .../actions/android/android_finalize_prechecks.rb | 3 +-- .../actions/android/android_get_alpha_version.rb | 3 +-- .../actions/android/android_get_app_version.rb | 3 +-- .../actions/android/android_get_release_version.rb | 3 +-- .../helper/android/android_version_helper.rb | 8 ++------ 11 files changed, 12 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37f166bfa..e38f22847 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ _None_ * Support for a version.properties to manage app versioning - all existing paths remain intact and new paths are only used when a version.properties file is present * Add support for providing an `app:` parameter to most versioning-related actions to allow support for multiple apps hosted in a monorepo + ### Bug Fixes * Some cleanup to how we scope variables in some of our actions diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index 9f043099a..95843b1de 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -8,7 +8,7 @@ def self.run(params) require_relative '../../helper/android/android_version_helper' Fastlane::Helper::GitHelper.ensure_on_branch!('release') - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] + app = params[:app] current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index 76c70c0c9..e3eb5e6ae 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -20,7 +20,7 @@ def self.run(params) UI.message("Current alpha version[#{app}]: #{current_version_alpha[vname]}(#{current_version_alpha[vcode]})") unless current_version_alpha.nil? UI.message("New release version[#{app}]: #{final_version[vname]}(#{final_version[vcode]})") - UI.message 'Updating version.properties...' + UI.message 'Updating app version...' Fastlane::Helper::Android::VersionHelper.update_versions(app, final_version, current_version_alpha) UI.message 'Done!' diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index ce80abb3c..98ca94c6c 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -11,7 +11,7 @@ def self.run(params) other_action.ensure_git_branch(branch: 'develop') # Create new configuration - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] + app = params[:app] new_short_version = Fastlane::Helper::Android::VersionHelper.bump_version_release(app) current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb index e441bcc69..2f0185e7b 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb @@ -14,7 +14,7 @@ def self.run(params) # Checkout develop and update Fastlane::Helper::GitHelper.checkout_and_pull('develop') - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] + app = params[:app] # Create versions current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb index 7950de058..bd48f9402 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb @@ -9,7 +9,7 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] + app = params[:app] version = Fastlane::Helper::Android::VersionHelper.get_public_version(app) message = "Completing code freeze for: [#{app}]#{version}\n" diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb index ec99c5d44..a959cc892 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb @@ -13,8 +13,7 @@ def self.run(params) UI.user_error!('This is not a release branch. Abort.') unless other_action.git_branch.start_with?('release/') - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] - version = Fastlane::Helper::Android::VersionHelper.get_public_version(app) + version = Fastlane::Helper::Android::VersionHelper.get_public_version(params[:app]) message = "Finalizing release: #{version}\n" if params[:skip_confirm] UI.message(message) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb index 997a00184..5de680bac 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb @@ -3,8 +3,7 @@ module Actions class AndroidGetAlphaVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper' - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] - Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) + Fastlane::Helper::Android::VersionHelper.get_alpha_version(params[:app]) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb index 193e59c40..e28fb6007 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb @@ -3,8 +3,7 @@ module Actions class AndroidGetAppVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper' - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] - Fastlane::Helper::Android::VersionHelper.get_public_version(app) + Fastlane::Helper::Android::VersionHelper.get_public_version(params[:app]) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index ae815821e..c574b9ee1 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -3,8 +3,7 @@ module Actions class AndroidGetReleaseVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper' - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] - Fastlane::Helper::Android::VersionHelper.get_release_version(app) + Fastlane::Helper::Android::VersionHelper.get_release_version(params[:app]) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index 4319dda72..a7ade313e 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -47,9 +47,7 @@ def self.get_public_version(app) # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # def self.get_release_version(app) - if properties_file_exists - return get_version_from_properties(product_name: app) - end + return get_version_from_properties(product_name: app) if properties_file_exists section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {' gradle_path = self.gradle_path @@ -100,9 +98,7 @@ def self.get_version_from_properties(product_name:, is_alpha: false) # or `nil` if `$HAS_ALPHA_VERSION` is not defined. # def self.get_alpha_version(app) - if properties_file_exists - return get_version_from_properties(product_name: app, is_alpha: true) - end + return get_version_from_properties(product_name: app, is_alpha: true) if properties_file_exists return nil if ENV['HAS_ALPHA_VERSION'].nil? From e2edf2650d42b7fb7c1cdc6b5be8b081484dbf24 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Tue, 15 Jun 2021 10:05:24 -0500 Subject: [PATCH 46/57] remove need for has_version_properties env var --- .../actions/android/android_bump_version_beta.rb | 4 ++-- .../actions/android/android_bump_version_final_release.rb | 4 ++-- .../actions/android/android_bump_version_hotfix.rb | 4 ++-- .../actions/android/android_bump_version_release.rb | 4 ++-- .../wpmreleasetoolkit/helper/android/android_git_helper.rb | 3 ++- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index 95843b1de..38b32bbc0 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -34,11 +34,11 @@ def self.run(params) ##################################################### def self.description - 'Bumps the version of the app for a new beta' + 'Bumps the version of the app for a new beta. Depends on a gradle task to update the keys in a version.properties file.' end def self.details - 'Bumps the version of the app for a new beta' + 'Bumps the version of the app for a new beta. Depends on a gradle task to update the keys in a version.properties file.' end def self.available_options diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index e3eb5e6ae..166d05588 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -32,11 +32,11 @@ def self.run(params) ##################################################### def self.description - 'Bumps the version of the app for a new beta' + 'Bumps the version of the app for a new beta. Depends on a gradle task to update the keys in a version.properties file.' end def self.details - 'Bumps the version of the app for a new beta' + 'Bumps the version of the app for a new beta. Depends on a gradle task to update the keys in a version.properties file.' end def self.available_options diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index cfd4cd701..47491bf5b 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -33,11 +33,11 @@ def self.run(params) ##################################################### def self.description - 'Bumps the version of the app and creates the new release branch' + 'Bumps the version of the app and creates the new release branch. Depends on a gradle task to update the keys in a version.properties file.' end def self.details - 'Bumps the version of the app and creates the new release branch' + 'Bumps the version of the app and creates the new release branch. Depends on a gradle task to update the keys in a version.properties file.' end def self.available_options diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index 98ca94c6c..f1b28cad0 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -45,11 +45,11 @@ def self.run(params) ##################################################### def self.description - 'Bumps the version of the app and creates the new release branch' + 'Bumps the version of the app and creates the new release branch. Depends on a gradle task to update the keys in a version.properties file.' end def self.details - 'Bumps the version of the app and creates the new release branch' + 'Bumps the version of the app and creates the new release branch. Depends on a gradle task to update the keys in a version.properties file.' end def self.available_options diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb index 8f8b353e6..b6fb0ee96 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb @@ -12,7 +12,8 @@ module GitHelper # @env PROJECT_NAME The name of the directory containing the project code (especially containing the `build.gradle` file) # def self.commit_version_bump - if ENV['HAS_VERSION_PROPERTIES'].nil? + require_relative './android_version_helper' + if Fastlane::Helper::Android::VersionHelper.properties_file_exists Fastlane::Helper::GitHelper.commit( message: 'Bump version number', files: File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'build.gradle'), From c10f33ff8840d2e4838767ea2fecb4de1c199417 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Tue, 15 Jun 2021 10:07:02 -0500 Subject: [PATCH 47/57] address comment to update variable --- .../actions/android/android_bump_version_beta.rb | 2 +- .../actions/android/android_bump_version_hotfix.rb | 2 +- .../actions/android/android_bump_version_release.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index 38b32bbc0..a6ecda0f8 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -22,7 +22,7 @@ def self.run(params) UI.message("New beta version[#{app}]: #{new_version_beta[vname]}(#{new_version_beta[vcode]})") UI.message("New alpha version[#{app}]: #{new_version_alpha[vname]}(#{new_version_alpha[vcode]})") unless current_version_alpha.nil? - UI.message 'Updating build.gradle...' + UI.message 'Updating app version...' Fastlane::Helper::Android::VersionHelper.update_versions(app, new_version_beta, new_version_alpha) UI.message 'Done!' diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 47491bf5b..7d185523b 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -19,7 +19,7 @@ def self.run(params) UI.message("New hotfix version[#{app}]: #{new_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{new_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]})") UI.message("Release branch: #{new_release_branch}") - UI.message 'Updating version.properties...' + UI.message 'Updating app version...' Fastlane::Helper::Android::VersionHelper.update_versions(app, new_version, current_version_alpha) UI.message 'Done!' diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index f1b28cad0..d39adc2c8 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -34,7 +34,7 @@ def self.run(params) Fastlane::Helper::GitHelper.create_branch(new_release_branch, from: 'develop') UI.message 'Done!' - UI.message 'Updating versions...' + UI.message 'Updating app version...' Fastlane::Helper::Android::VersionHelper.update_versions(app, new_version_beta, new_version_alpha) Fastlane::Helper::Android::GitHelper.commit_version_bump() UI.message 'Done.' From 3987111b373d108d99080954a51fc21419c5515a Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Tue, 15 Jun 2021 10:08:27 -0500 Subject: [PATCH 48/57] update Changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e38f22847..0e917ad27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ ### Breaking Changes -_None_ +* Clients adopting the new version.properties will need to implement a gradle task to update the version.properties file named `updateVersionProperties` ### New Features From fb76ece0bbc8ffa5f72f70828c4dce32e919e39f Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Tue, 15 Jun 2021 10:16:20 -0500 Subject: [PATCH 49/57] address existing instances of app variable assignment using env var explicitly --- .../actions/android/android_bump_version_final_release.rb | 2 +- .../actions/android/android_bump_version_hotfix.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index 166d05588..a1fd73aae 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -8,7 +8,7 @@ def self.run(params) require_relative '../../helper/android/android_version_helper' Fastlane::Helper::GitHelper.ensure_on_branch!('release') - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] + app = params[:app] current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 7d185523b..61dc7cc1f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -7,7 +7,7 @@ def self.run(params) require_relative '../../helper/android/android_git_helper' Fastlane::Helper::GitHelper.create_branch("release/#{params[:version_name]}", from: params[:previous_version_name]) - app = ENV['PROJECT_NAME'].nil? ? params[:app] : ENV['PROJECT_NAME'] + app = params[:app] current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) From 2e3a8e24810e4970633358631a309f99b310ef88 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Tue, 15 Jun 2021 10:24:42 -0500 Subject: [PATCH 50/57] update Changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e917ad27..d17a3ee3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * Support for a version.properties to manage app versioning - all existing paths remain intact and new paths are only used when a version.properties file is present * Add support for providing an `app:` parameter to most versioning-related actions to allow support for multiple apps hosted in a monorepo +* Supporting the new version.properties file also allows for the HAS_ALPHA_VERSION variable to be removed as the alpha reference in the properties file will be used going forward. ### Bug Fixes From bf140999933e52526151eaf2571f23d68eb5a8d6 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Tue, 15 Jun 2021 10:35:41 -0500 Subject: [PATCH 51/57] update Changelog --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d17a3ee3e..630900d22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,13 +6,12 @@ ### Breaking Changes -* Clients adopting the new version.properties will need to implement a gradle task to update the version.properties file named `updateVersionProperties` - ### New Features * Support for a version.properties to manage app versioning - all existing paths remain intact and new paths are only used when a version.properties file is present * Add support for providing an `app:` parameter to most versioning-related actions to allow support for multiple apps hosted in a monorepo -* Supporting the new version.properties file also allows for the HAS_ALPHA_VERSION variable to be removed as the alpha reference in the properties file will be used going forward. +* Supporting the new version.properties file also allows for the HAS_ALPHA_VERSION variable to be removed as the alpha reference in the properties file will be used going forward. +* Clients adopting the new version.properties will need to implement a gradle task to update the version.properties file named `updateVersionProperties` ### Bug Fixes From 1e7c77a9688fbef7e4c46771b47025489d1c464e Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 16 Jun 2021 22:13:44 -0400 Subject: [PATCH 52/57] update details in bump actions to include name of gradle task --- .../actions/android/android_bump_version_beta.rb | 4 ++-- .../actions/android/android_bump_version_final_release.rb | 4 ++-- .../actions/android/android_bump_version_hotfix.rb | 4 ++-- .../actions/android/android_bump_version_release.rb | 4 ++-- .../actions/android/android_get_alpha_version.rb | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index a6ecda0f8..ab65a32c7 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -34,11 +34,11 @@ def self.run(params) ##################################################### def self.description - 'Bumps the version of the app for a new beta. Depends on a gradle task to update the keys in a version.properties file.' + 'Bumps the version of the app for a new beta. Requires the `updateVersionProperties` gradle task to update the keys if you are using a `version.properties` file.' end def self.details - 'Bumps the version of the app for a new beta. Depends on a gradle task to update the keys in a version.properties file.' + 'Bumps the version of the app for a new beta. Requires the `updateVersionProperties` gradle task to update the keys if you are using a `version.properties` file.' end def self.available_options diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index a1fd73aae..ff1c4a93c 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -32,11 +32,11 @@ def self.run(params) ##################################################### def self.description - 'Bumps the version of the app for a new beta. Depends on a gradle task to update the keys in a version.properties file.' + 'Bumps the version of the app for a new beta. Requires the `updateVersionProperties` gradle task to update the keys if you are using a `version.properties` file.' end def self.details - 'Bumps the version of the app for a new beta. Depends on a gradle task to update the keys in a version.properties file.' + 'Bumps the version of the app for a new beta. Requires the `updateVersionProperties` gradle task to update the keys if you are using a `version.properties` file.' end def self.available_options diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 61dc7cc1f..7020313c8 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -33,11 +33,11 @@ def self.run(params) ##################################################### def self.description - 'Bumps the version of the app and creates the new release branch. Depends on a gradle task to update the keys in a version.properties file.' + 'Bumps the version of the app for a new beta. Requires the `updateVersionProperties` gradle task to update the keys if you are using a `version.properties` file.' end def self.details - 'Bumps the version of the app and creates the new release branch. Depends on a gradle task to update the keys in a version.properties file.' + 'Bumps the version of the app for a new beta. Requires the `updateVersionProperties` gradle task to update the keys if you are using a `version.properties` file.' end def self.available_options diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index d39adc2c8..3a0367c5a 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -45,11 +45,11 @@ def self.run(params) ##################################################### def self.description - 'Bumps the version of the app and creates the new release branch. Depends on a gradle task to update the keys in a version.properties file.' + 'Bumps the version of the app for a new beta. Requires the `updateVersionProperties` gradle task to update the keys if you are using a `version.properties` file.' end def self.details - 'Bumps the version of the app and creates the new release branch. Depends on a gradle task to update the keys in a version.properties file.' + 'Bumps the version of the app for a new beta. Requires the `updateVersionProperties` gradle task to update the keys if you are using a `version.properties` file.' end def self.available_options diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb index 5de680bac..4211aff91 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb @@ -23,7 +23,7 @@ def self.available_options [ FastlaneCore::ConfigItem.new(key: :app, env_name: 'PROJECT_NAME', - description: 'TThe name of the app to get the release version for', + description: 'The name of the app to get the release version for', is_string: true), # true: verifies the input is a string, false: every kind of value ] end From 841e8da5a3e145ce11bfe78de71e1523e4fe6056 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 16 Jun 2021 22:14:30 -0400 Subject: [PATCH 53/57] fix inverted logic in commit helper --- .../wpmreleasetoolkit/helper/android/android_git_helper.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb index b6fb0ee96..5e50f8c7d 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb @@ -16,13 +16,13 @@ def self.commit_version_bump if Fastlane::Helper::Android::VersionHelper.properties_file_exists Fastlane::Helper::GitHelper.commit( message: 'Bump version number', - files: File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'build.gradle'), + files: File.join(ENV['PROJECT_ROOT_FOLDER'], 'version.properties'), push: true ) else Fastlane::Helper::GitHelper.commit( message: 'Bump version number', - files: File.join(ENV['PROJECT_ROOT_FOLDER'], 'version.properties'), + files: File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'build.gradle'), push: true ) end From 3496330f2c4e3fea73e40cc2c52e08647305ff81 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 16 Jun 2021 22:18:53 -0400 Subject: [PATCH 54/57] update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 630900d22..b4ef85372 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ * Support for a version.properties to manage app versioning - all existing paths remain intact and new paths are only used when a version.properties file is present * Add support for providing an `app:` parameter to most versioning-related actions to allow support for multiple apps hosted in a monorepo * Supporting the new version.properties file also allows for the HAS_ALPHA_VERSION variable to be removed as the alpha reference in the properties file will be used going forward. -* Clients adopting the new version.properties will need to implement a gradle task to update the version.properties file named `updateVersionProperties` +* Clients adopting the new `version.properties` will need to implement a gradle task named `updateVersionProperties` to update the `version.properties` file. ### Bug Fixes From 354de4e75a617fb043cd3209c926797a2951c798 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 16 Jun 2021 22:22:51 -0400 Subject: [PATCH 55/57] update changelog --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4ef85372..792b511cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,9 +8,9 @@ ### New Features -* Support for a version.properties to manage app versioning - all existing paths remain intact and new paths are only used when a version.properties file is present +* Support for a `version.properties` to manage app versioning - all existing paths remain intact and new paths are only used when a `version.properties` file is present. * Add support for providing an `app:` parameter to most versioning-related actions to allow support for multiple apps hosted in a monorepo -* Supporting the new version.properties file also allows for the HAS_ALPHA_VERSION variable to be removed as the alpha reference in the properties file will be used going forward. +* Supporting the new `version.properties` file also allows for the `HAS_ALPHA_VERSION` variable to be removed as the alpha reference in the properties file will be used going forward. * Clients adopting the new `version.properties` will need to implement a gradle task named `updateVersionProperties` to update the `version.properties` file. ### Bug Fixes From b58fc23fac980dc366585307cb93914f22702973 Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Wed, 16 Jun 2021 22:45:27 -0400 Subject: [PATCH 56/57] address shallow clone issue on ci --- .circleci/config.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index e8a1a4836..7c9a0e8ed 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -21,7 +21,11 @@ commands: steps: - run: name: Install Homebrew dependencies, if neeeded - command: brew update && xargs brew install --verbose < .circleci/.brewfile + command: | + # Because the CircleCI image uses shallow clones, we need to unshallow them first. See https://bit.ly/3vx6EAL + git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow + git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow + brew update && xargs brew install --verbose < .circleci/.brewfile - run: name: Install Ruby dependencies, if neeeded command: bundle check --path vendor/bundle || bundle install --with screenshots @@ -57,7 +61,7 @@ jobs: # Save test results for timing analysis - store_test_results: path: test_results - + # Coverage reports are sent to Codecov as part of running `rspec`, not as a CircleCI step. # We may wish to change this for consistency. @@ -94,4 +98,3 @@ workflows: only: /.*/ branches: ignore: /.*/ - From b695e165a38d3ad373c2f316c3bcfb9f4d34e6ce Mon Sep 17 00:00:00 2001 From: Javon Davis Date: Fri, 18 Jun 2021 11:55:37 -0500 Subject: [PATCH 57/57] update get_release version callsites --- .../actions/android/android_bump_version_beta.rb | 2 +- .../actions/android/android_bump_version_final_release.rb | 2 +- .../actions/android/android_bump_version_hotfix.rb | 2 +- .../actions/android/android_bump_version_release.rb | 2 +- .../actions/android/android_codefreeze_prechecks.rb | 2 +- .../actions/android/android_current_branch_is_hotfix.rb | 2 +- .../actions/android/android_get_release_version.rb | 2 +- .../helper/android/android_version_helper.rb | 6 +++--- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb index ab65a32c7..5023c1478 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb @@ -10,7 +10,7 @@ def self.run(params) Fastlane::Helper::GitHelper.ensure_on_branch!('release') app = params[:app] - current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(product_name: app) current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_beta_version(current_version, current_version_alpha) new_version_alpha = current_version_alpha.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(new_version_beta, current_version_alpha) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb index ff1c4a93c..e271ea784 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb @@ -10,7 +10,7 @@ def self.run(params) Fastlane::Helper::GitHelper.ensure_on_branch!('release') app = params[:app] - current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(product_name: app) current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) final_version = Fastlane::Helper::Android::VersionHelper.calc_final_release_version(current_version, current_version_alpha) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb index 7020313c8..d9e4faaac 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb @@ -9,7 +9,7 @@ def self.run(params) app = params[:app] - current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(product_name: app) current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) new_version = Fastlane::Helper::Android::VersionHelper.calc_next_hotfix_version(params[:version_name], params[:version_code]) new_short_version = new_version_name diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb index 3a0367c5a..9372eeaef 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb @@ -14,7 +14,7 @@ def self.run(params) app = params[:app] new_short_version = Fastlane::Helper::Android::VersionHelper.bump_version_release(app) - current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(product_name: app) current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_release_version(current_version, current_version_alpha) new_version_alpha = current_version_alpha.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(new_version_beta, current_version_alpha) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb index 2f0185e7b..127fde44f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb @@ -17,7 +17,7 @@ def self.run(params) app = params[:app] # Create versions - current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(app) + current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(product_name: app) current_alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(app) next_version = Fastlane::Helper::Android::VersionHelper.calc_next_release_version(current_version, current_alpha_version) next_alpha_version = current_alpha_version.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(next_version, current_alpha_version) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb index 03d593dcb..7c61e9c0b 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb @@ -7,7 +7,7 @@ module SharedValues class AndroidCurrentBranchIsHotfixAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper' - version = Fastlane::Helper::Android::VersionHelper.get_release_version(params[:app]) + version = Fastlane::Helper::Android::VersionHelper.get_release_version(product_name: params[:app]) Fastlane::Helper::Android::VersionHelper.is_hotfix?(version) end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb index c574b9ee1..71e605cb1 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb @@ -3,7 +3,7 @@ module Actions class AndroidGetReleaseVersionAction < Action def self.run(params) require_relative '../../helper/android/android_version_helper' - Fastlane::Helper::Android::VersionHelper.get_release_version(params[:app]) + Fastlane::Helper::Android::VersionHelper.get_release_version(product_name: params[:app]) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb index a7ade313e..181e40149 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb @@ -46,8 +46,8 @@ def self.get_public_version(app) # # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively # - def self.get_release_version(app) - return get_version_from_properties(product_name: app) if properties_file_exists + def self.get_release_version(product_name:) + return get_version_from_properties(product_name: product_name) if properties_file_exists section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {' gradle_path = self.gradle_path @@ -300,7 +300,7 @@ def self.is_hotfix?(version) # def self.bump_version_release(app) # Bump release - current_version = get_release_version(app) + current_version = get_release_version(product_name: app) UI.message("Current version: #{current_version[VERSION_NAME]}") new_version = calc_next_release_base_version(current_version) UI.message("New version: #{new_version[VERSION_NAME]}")