From 750b66efeacd2a28f44c7f35e0e75bb45e9aa823 Mon Sep 17 00:00:00 2001 From: Spencer Transier Date: Sat, 31 Aug 2024 00:12:40 -0700 Subject: [PATCH 1/2] Remove unneeded iOS versioning actions --- .../actions/common/close_milestone_action.rb | 2 - .../common/create_new_milestone_action.rb | 1 - .../actions/common/create_release_action.rb | 2 - .../actions/ios/ios_check_beta_deps.rb | 2 - .../ios/ios_current_branch_is_hotfix.rb | 40 --- .../actions/ios/ios_get_app_version.rb | 54 ---- .../actions/ios/ios_get_build_number.rb | 54 ---- .../actions/ios/ios_get_build_version.rb | 60 ---- .../actions/ios/ios_tag_build.rb | 44 --- .../actions/ios/ios_validate_ci_build.rb | 46 --- .../wpmreleasetoolkit/helper/git_helper.rb | 27 -- .../helper/ios/ios_version_helper.rb | 270 ------------------ spec/ios_get_app_version_spec.rb | 87 ------ spec/ios_get_build_number_spec.rb | 63 ---- 14 files changed, 752 deletions(-) delete mode 100644 lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_current_branch_is_hotfix.rb delete mode 100644 lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb delete mode 100644 lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_number.rb delete mode 100644 lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_version.rb delete mode 100644 lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb delete mode 100644 lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb delete mode 100644 spec/ios_get_app_version_spec.rb delete mode 100644 spec/ios_get_build_number_spec.rb diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/close_milestone_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/close_milestone_action.rb index 72cbecfa6..8a97d39e5 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/close_milestone_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/close_milestone_action.rb @@ -1,8 +1,6 @@ require 'fastlane/action' require 'date' require_relative '../../helper/github_helper' -require_relative '../../helper/ios/ios_version_helper' -require_relative '../../helper/android/android_version_helper' module Fastlane module Actions class CloseMilestoneAction < Action diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb index 505814e22..2045fae70 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb @@ -2,7 +2,6 @@ require 'date' require_relative '../../helper/github_helper' require_relative '../../helper/ios/ios_version_helper' -require_relative '../../helper/android/android_version_helper' module Fastlane module Actions class CreateNewMilestoneAction < Action diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb index f294a362b..3ef81ab14 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb @@ -1,8 +1,6 @@ require 'fastlane/action' require 'date' require_relative '../../helper/github_helper' -require_relative '../../helper/ios/ios_version_helper' -require_relative '../../helper/android/android_version_helper' module Fastlane module Actions class CreateReleaseAction < Action diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb index 8a1123ad9..1bead6ab6 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb @@ -7,8 +7,6 @@ class IosCheckBetaDepsAction < Action NON_STABLE_PODS_MESSAGE = "Please create a new stable version of those pods and update the Podfile to the newly released version before continuing with the code freeze:\n".freeze def self.run(params) - require_relative '../../helper/ios/ios_version_helper' - yaml = YAML.load_file(params[:lockfile]) non_stable_pods = {} # Key will be pod name, value will be reason for flagging diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_current_branch_is_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_current_branch_is_hotfix.rb deleted file mode 100644 index fc0ab8fcb..000000000 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_current_branch_is_hotfix.rb +++ /dev/null @@ -1,40 +0,0 @@ -module Fastlane - module Actions - class IosCurrentBranchIsHotfixAction < Action - def self.run(params) - require_relative '../../helper/ios/ios_version_helper' - Fastlane::Helper::Ios::VersionHelper.is_hotfix?(Fastlane::Helper::Ios::VersionHelper.get_public_version) - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - 'Checks if the current branch is for a hotfix' - end - - def self.details - 'Checks if the current branch is for a hotfix' - end - - def self.available_options - end - - def self.output - end - - def self.return_value - 'True if the branch is for a hotfix, false otherwise' - end - - def self.authors - ['Automattic'] - end - - def self.is_supported?(platform) - %i[ios mac].include?(platform) - end - end - end -end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb deleted file mode 100644 index c377475c6..000000000 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb +++ /dev/null @@ -1,54 +0,0 @@ -module Fastlane - module Actions - class IosGetAppVersionAction < Action - def self.run(params) - require_relative '../../helper/ios/ios_version_helper' - - public_version_xcconfig_file = params[:public_version_xcconfig_file] - Fastlane::Helper::Ios::VersionHelper.get_xcconfig_public_version(xcconfig_file: public_version_xcconfig_file) - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - 'Gets the public version of the app' - end - - def self.details - 'Gets the public version of the app' - end - - def self.available_options - [ - FastlaneCore::ConfigItem.new( - key: :public_version_xcconfig_file, - env_name: 'FL_IOS_PUBLIC_VERSION_XCCONFIG_FILE', - description: 'Path to the .xcconfig file containing the public app version', - type: String, - optional: false - ), - ] - end - - def self.output - # Define the shared values you are going to provide - end - - def self.return_value - # If you method provides a return value, you can describe here what it does - 'Return the public version of the app' - end - - def self.authors - # So no one will ever forget your contribution to fastlane :) You are awesome btw! - ['Automattic'] - end - - def self.is_supported?(platform) - %i[ios mac].include?(platform) - end - end - end -end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_number.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_number.rb deleted file mode 100644 index dc9fc6e62..000000000 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_number.rb +++ /dev/null @@ -1,54 +0,0 @@ -module Fastlane - module Actions - class IosGetBuildNumberAction < Action - def self.run(params) - require_relative '../../helper/ios/ios_version_helper' - - xcconfig_file_path = params[:xcconfig_file_path] - Fastlane::Helper::Ios::VersionHelper.read_build_number_from_config_file(xcconfig_file_path) - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - 'Gets the build number of the app' - end - - def self.details - 'Gets the build number of the app' - end - - def self.available_options - [ - FastlaneCore::ConfigItem.new( - key: :xcconfig_file_path, - env_name: 'FL_IOS_XCCONFIG_FILE_PATH', - description: 'Path to the .xcconfig file containing the build number', - type: String, - optional: false - ), - ] - end - - def self.output - # Define the shared values you are going to provide - end - - def self.return_value - # If you method provides a return value, you can describe here what it does - 'Return the build number of the app' - end - - def self.authors - # So no one will ever forget your contribution to fastlane :) You are awesome btw! - ['Automattic'] - end - - def self.is_supported?(platform) - %i[ios mac].include?(platform) - end - end - end -end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_version.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_version.rb deleted file mode 100644 index 4de0a0137..000000000 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_version.rb +++ /dev/null @@ -1,60 +0,0 @@ -module Fastlane - module Actions - class IosGetBuildVersionAction < Action - def self.run(params) - require_relative '../../helper/ios/ios_version_helper' - - UI.user_error!('You need to set at least the PUBLIC_CONFIG_FILE env var to the path to the public xcconfig file') unless ENV['PUBLIC_CONFIG_FILE'] - - if params[:internal] - UI.user_error!('You need to set the INTERNAL_CONFIG_FILE env var to the path to the internal xcconfig file') unless ENV['INTERNAL_CONFIG_FILE'] - Fastlane::Helper::Ios::VersionHelper.get_internal_version - else - Fastlane::Helper::Ios::VersionHelper.get_build_version - end - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - 'Gets the build version of the app' - end - - def self.details - 'Gets the build version (`VERSION_LONG`) of the app from the xcconfig file' - end - - def self.available_options - [ - FastlaneCore::ConfigItem.new( - key: :internal, - env_name: 'FL_IOS_BUILD_VERSION_INTERNAL', - description: 'If true, returns the internal build version, otherwise returns the public one', - type: Boolean, - default_value: false - ), - ] - end - - def self.output - # Define the shared values you are going to provide - end - - def self.return_value - # If you method provides a return value, you can describe here what it does - 'Return the public or internal build version of the app' - end - - def self.authors - # So no one will ever forget your contribution to fastlane :) You are awesome btw! - ['Automattic'] - end - - def self.is_supported?(platform) - %i[ios mac].include?(platform) - end - end - end -end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb deleted file mode 100644 index af976e708..000000000 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb +++ /dev/null @@ -1,44 +0,0 @@ -module Fastlane - module Actions - class IosTagBuildAction < Action - def self.run(params) - require_relative '../../helper/ios/ios_version_helper' - require_relative '../../helper/git_helper' - - itc_ver = Fastlane::Helper::Ios::VersionHelper.get_build_version - int_ver = Fastlane::Helper::Ios::VersionHelper.get_internal_version unless ENV['INTERNAL_CONFIG_FILE'].nil? - Fastlane::Helper::GitHelper.create_tag(itc_ver) - Fastlane::Helper::GitHelper.create_tag(int_ver) unless int_ver.nil? - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - 'Tags the current build' - end - - def self.details - 'Tags the current build' - end - - def self.available_options - end - - def self.output - end - - def self.return_value - end - - def self.authors - ['Automattic'] - end - - def self.is_supported?(platform) - %i[ios mac].include?(platform) - end - end - end -end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb deleted file mode 100644 index b38dbe1fc..000000000 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb +++ /dev/null @@ -1,46 +0,0 @@ -module Fastlane - module Actions - class IosValidateCiBuildAction < Action - def self.run(params) - return_value '../../helper/git_helper' - require_relative '../../helper/ios/ios_version_helper' - - version = Fastlane::Helper::Ios::VersionHelper.get_public_version - head_tags = Fastlane::Helper::GitHelper.list_tags_on_current_commit - UI.user_error!('HEAD is not on tag. Aborting!') if head_tags.empty? - - head_tags.include?(version) # Current commit is tagged with "version" tag - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - 'Validate the build on CI environment' - end - - def self.details - 'Validate the build on CI environment' - end - - def self.available_options - [] - end - - def self.output - end - - def self.return_value - end - - def self.authors - ['Automattic'] - end - - def self.is_supported?(platform) - %i[ios mac].include?(platform) - end - end - end -end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb index 342579046..771923533 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb @@ -67,15 +67,6 @@ def self.checkout_and_pull(branch) false end - # Update every submodule in the current git repository - # - # @deprecated This method is going to be removed soon. Fastlane has a built-in `git_submodule_update` action that can be used instead. - # - def self.update_submodules - UI.deprecated("The `update_submodules` method will soon be removed from `release-toolkit`. Please use fastlane's `git_submodule_update` action instead.") - Action.sh('git', 'submodule', 'update', '--init', '--recursive') - end - # Create a new branch named `branch_name`, cutting it from branch/commit/tag `from` # # If the branch with that name already exists, it will instead switch to it and pull new commits. @@ -232,24 +223,6 @@ def self.branch_exists_on_remote?(branch_name:, remote_name: 'origin') !Action.sh('git', 'ls-remote', '--heads', remote_name, branch_name).empty? end - # Ensure that we are on the expected branch, and abort if not. - # - # @param [String] branch_name The name of the branch we expect to be on - # - # @raise [UserError] Raises a user_error! and interrupts the lane if we are not on the expected branch. - # - # @deprecated This method is going to be removed soon. Fastlane has a built-in `ensure_git_branch` action that can be used instead. - # After updating to Fastlane version `2.217.0` or later, the `FL_GIT_BRANCH_DONT_USE_ENV_VARS` environment - # variable can be set to `true` to disable the use of environment variables for the `git_branch` action that - # `ensure_git_branch` relies on. This will make `ensure_git_branch` work as expected in CI environments. - # See https://github.com/fastlane/fastlane/pull/21597 for more details. - # - def self.ensure_on_branch!(branch_name) - UI.deprecated("The `ensure_on_branch!` method will soon be removed from `release-toolkit`. Please use fastlane's `ensure_git_branch` action (+ potentially set `FL_GIT_BRANCH_DONT_USE_ENV_VARS=true`) instead.") - current_branch_name = Action.sh('git', 'symbolic-ref', '-q', 'HEAD') - UI.user_error!("This command works only on #{branch_name} branch") unless current_branch_name.include?(branch_name) - end - # Checks whether a given path is ignored by Git, relying on Git's `check-ignore` under the hood. # # @param [String] path The path to check against `.gitignore` diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb index 50ebba2e8..02ea7c349 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb @@ -15,41 +15,6 @@ module VersionHelper # The index for the build version number part BUILD_NUMBER = 3 - # Returns the public-facing version string. - # - # @param [String] xcconfig_file The path for the .xcconfig file containing the public-facing version - # - # @return [String] The public-facing version number, extracted from the VERSION_LONG entry of the xcconfig 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 - # - def self.get_xcconfig_public_version(xcconfig_file:) - version = read_long_version_from_config_file(xcconfig_file) - - UI.user_error!(".xcconfig file doesn't have a version configured") if version.nil? - - vp = get_version_parts(version) - return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" unless is_hotfix?(version) - - "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}" - end - - # Returns the public-facing version string. - # - # @return [String] The public-facing version number, extracted from the VERSION_LONG entry of the xcconfig 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 - # - # @deprecated This method is going to be removed soon due to it's dependency on `ENV['PUBLIC_CONFIG_FILE']` via `get_build_version`. - # - def self.get_public_version - version = get_build_version - vp = get_version_parts(version) - return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" unless is_hotfix?(version) - - "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}" - end - # Compute the name of the next release version. # # @param [String] version The current version that we want to increment @@ -69,193 +34,6 @@ def self.calc_next_release_version(version) "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" end - # Return the short version string "X.Y" from the full version. - # - # @param [String] version The version to convert to a short version - # - # @return [String] A version string consisting of only the first 2 parts "X.Y" - # - def self.get_short_version_string(version) - vp = get_version_parts(version) - "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" - end - - # Compute the name of the previous release version. - # - # @param [String] version The current version we want to decrement - # - # @return [String] The predicted previous version, in the form of "X.Y". - # Corresponds to decrementing the minor part, or decrement the major and set minor to 9 if minor was 0. - # - def self.calc_prev_release_version(version) - vp = get_version_parts(version) - if (vp[MINOR_NUMBER]).zero? - vp[MAJOR_NUMBER] -= 1 - vp[MINOR_NUMBER] = 9 - else - vp[MINOR_NUMBER] -= 1 - end - - "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" - end - - # Compute the name of the next build version. - # - # @param [String] version The current version we want to increment - # - # @return [String] The predicted next build version, in the form of "X.Y.Z.N". - # Corresponds to incrementing the last (4th) component N of the version. - # - def self.calc_next_build_version(version) - vp = get_version_parts(version) - vp[BUILD_NUMBER] += 1 - "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}.#{vp[BUILD_NUMBER]}" - end - - # Compute the name of the next hotfix version. - # - # @param [String] version The current version we want to increment - # - # @return [String] The predicted next hotfix version, in the form of "X.Y.Z". - # Corresponds to incrementing the 3rd component of the version. - # - def self.calc_next_hotfix_version(version) - vp = get_version_parts(version) - vp[HOTFIX_NUMBER] += 1 - "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}" - end - - # Compute the name of the previous build version. - # - # @param [String] version The current version we want to decrement - # - # @return [String] The predicted previous build version, in the form of "X.Y.Z.N". - # Corresponds to decrementing the last (4th) component N of the version. - # - def self.calc_prev_build_version(version) - vp = get_version_parts(version) - vp[BUILD_NUMBER] -= 1 unless (vp[BUILD_NUMBER]).zero? - "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}.#{vp[BUILD_NUMBER]}" - end - - # Compute the name of the previous hotfix version. - # - # @param [String] version The current version we want to decrement - # - # @return [String] The predicted previous hotfix version, in the form of "X.Y.Z", or "X.Y" if Z is 0. - # Corresponds to decrementing the 3rd component Z of the version, striping it if it ends up being zero. - # - def self.calc_prev_hotfix_version(version) - vp = get_version_parts(version) - vp[HOTFIX_NUMBER] -= 1 unless (vp[HOTFIX_NUMBER]).zero? - return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}" unless (vp[HOTFIX_NUMBER]).zero? - - "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" - end - - # Create an internal version number, for which the build number is based on today's date. - # - # @param [String] version The current version to create an internal version name for. - # - # @return [String] The internal version, in the form of "X.Y.Z.YYYYMMDD". - # - def self.create_internal_version(version) - vp = get_version_parts(version) - d = DateTime.now - today_date = d.strftime('%Y%m%d') - "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}.#{today_date}" - end - - # Return the build number value incremented by one. - # - # @param [String|Int|nil] build_number The build number to increment - # - # @return [Int] The incremented build number, or 0 if it was `nil`. - # - def self.bump_build_number(build_number) - build_number.nil? ? 0 : build_number.to_i + 1 - end - - # Determines if a version number corresponds to a hotfix - # - # @param [String] version The version number to test - # - # @return [Bool] True if the version number has a non-zero 3rd component, meaning that it is a hotfix version. - # - def self.is_hotfix?(version) - vp = get_version_parts(version) - (vp.length > 2) && (vp[HOTFIX_NUMBER] != 0) - end - - # Returns the current value of the `VERSION_LONG` key from the public xcconfig file - # - # @return [String] The current version according to the public xcconfig file. - # - def self.get_build_version - xcconfig_file = ENV['PUBLIC_CONFIG_FILE'] - read_long_version_from_config_file(xcconfig_file) - end - - # Returns the current value of the `VERSION_LONG` key from the internal xcconfig file - # - # @return [String] The current version according to the internal xcconfig file. - # - def self.get_internal_version - xcconfig_file = ENV['INTERNAL_CONFIG_FILE'] - read_long_version_from_config_file(xcconfig_file) - end - - # Prints the current and next release version numbers to stdout, then return the next release version - # - # @return [String] The next release version to use after bumping the currently used public version. - # - def self.bump_version_release - # Bump release - current_version = get_public_version - UI.message("Current version: #{current_version}") - new_version = calc_next_release_version(current_version) - UI.message("New version: #{new_version}") - verify_version(new_version) - end - - # Update the `.xcconfig` files (the public one, and the internal one if it exists) with the new version strings. - # - # @env PUBLIC_CONFIG_FILE The path to the xcconfig file containing the public version numbers. - # @env INTERNAL_CONFIG_FILE The path to the xcconfig file containing the internal version numbers. Can be nil. - # - # @param [String] new_version The new version number to use as `VERSION_LONG` for the public xcconfig file - # @param [String] new_version_short The new version number to use for `VERSION_SHORT` (for both public and internal xcconfig files) - # @param [String] internal_version The new version number to use as `VERSION_LONG` for the interrnal xcconfig file, if it exists - # - def self.update_xc_configs(new_version, new_version_short, internal_version) - update_xc_config(ENV['PUBLIC_CONFIG_FILE'], new_version, new_version_short) - update_xc_config(ENV['INTERNAL_CONFIG_FILE'], internal_version, new_version_short) unless ENV['INTERNAL_CONFIG_FILE'].nil? - end - - # Updates an xcconfig file with new values for VERSION_SHORT and VERSION_LONG entries. - # Also bumps the BUILD_NUMBER value from that config file if there is one present. - # - # @param [String] file_path The path to the xcconfig file - # @param [String] new_version The new version number to use for VERSION_LONG - # @param [String] new_version_short The new version number to use for VERSION_SHORT - # @raise [UserError] If the xcconfig file was not found - # - def self.update_xc_config(file_path, new_version, new_version_short) - if File.exist?(file_path) - UI.message("Updating #{file_path} to version #{new_version_short}/#{new_version}") - Action.sh("sed -i '' \"$(awk '/^VERSION_SHORT/{ print NR; exit }' \"#{file_path}\")s/=.*/=#{new_version_short}/\" \"#{file_path}\"") - Action.sh("sed -i '' \"$(awk '/^VERSION_LONG/{ print NR; exit }' \"#{file_path}\")s/=.*/=#{new_version}/\" \"#{file_path}\"") - - build_number = read_build_number_from_config_file(file_path) - unless build_number.nil? - new_build_number = bump_build_number(build_number) - Action.sh("sed -i '' \"$(awk '/^BUILD_NUMBER/{ print NR; exit }' \"#{file_path}\")s/=.*/=#{new_build_number}/\" \"#{file_path}\"") - end - else - UI.user_error!("#{file_path} not found") - end - end - #---------------------------------------- # Split a version string into its 4 parts, ensuring its parts count is valid @@ -273,54 +51,6 @@ def self.get_version_parts(version) parts end - # Extract the VERSION_LONG entry from an `xcconfig` file - # - # @param [String] file_path The path to the `.xcconfig` file to read the value from - # @return [String] The long version found in said xcconfig file, or nil if not found - # - def self.read_long_version_from_config_file(file_path) - read_from_config_file('VERSION_LONG', file_path) - end - - # Extract the BUILD_NUMBER entry from an `xcconfig` file - # - # @param [String] file_path The path to the `.xcconfig` file to read the value from - # @return [String] The build number found in said xcconfig file, or nil if not found - # - def self.read_build_number_from_config_file(file_path) - read_from_config_file('BUILD_NUMBER', file_path) - end - - # Read the value of a given key from an `.xcconfig` file. - # - # @param [String] key The xcconfig key to get the value for - # @param [String] file_path The path to the `.xcconfig` file to read the value from - # - # @return [String] The value for the given key, or `nil` if the key was not found. - # - def self.read_from_config_file(key, file_path) - UI.user_error!(".xcconfig file #{file_path} not found") unless File.exist?(file_path) - - config = Xcodeproj::Config.new(file_path) - config.attributes[key] - end - - # Ensure that the version provided is only composed of number parts and return the validated string - # - # @param [String] version The version string to validate - # @return [String] The version string, re-validated as being a string of the form `X.Y.Z.T` - # @raise [UserError] Interrupts the lane with a user_error! if the version contains non-numberic parts - # - def self.verify_version(version) - v_parts = get_version_parts(version) - - v_parts.each do |part| - UI.user_error!('Version value can only contains numbers.') unless is_int?(part) - end - - "#{v_parts[MAJOR_NUMBER]}.#{v_parts[MINOR_NUMBER]}.#{v_parts[HOTFIX_NUMBER]}.#{v_parts[BUILD_NUMBER]}" - end - # Check if a string is an integer # # @param [String] string The string to test diff --git a/spec/ios_get_app_version_spec.rb b/spec/ios_get_app_version_spec.rb deleted file mode 100644 index 0355fd175..000000000 --- a/spec/ios_get_app_version_spec.rb +++ /dev/null @@ -1,87 +0,0 @@ -require 'spec_helper' - -describe Fastlane::Actions::IosGetAppVersionAction do - describe 'getting the public app version from the provided .xcconfig file' do - it 'parses the xcconfig file format correctly and gets the public version' do - xcconfig_mock_content = <<~CONTENT - // a comment - VERSION_SHORT = 6 - VERSION_LONG = 6.30.0 - CONTENT - - expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30') - end - - it 'parses the xcconfig file format correctly and gets the public hotfix version' do - xcconfig_mock_content = <<~CONTENT - VERSION_SHORT = 6 - // a comment - VERSION_LONG = 6.30.1 - CONTENT - - expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30.1') - end - - it 'parses the xcconfig with keys without spacing and gets the public version' do - xcconfig_mock_content = <<~CONTENT - // a comment - VERSION_SHORT=6 - VERSION_LONG=6.30.0 - CONTENT - - expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30') - end - - it 'parses the xcconfig with keys without spacing and gets the public hotfix version' do - xcconfig_mock_content = <<~CONTENT - VERSION_SHORT=6 - // a comment - VERSION_LONG=6.30.1 - CONTENT - - expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30.1') - end - - it 'fails to extract the version from an xcconfig file with an invalid format' do - xcconfig_mock_content = <<~CONTENT - VERSION_SHORT = 6 - VERSION_LONG 6.30.1 - CONTENT - - expect do - expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: 'n/a') - end.to raise_error(FastlaneCore::Interface::FastlaneError) - end - - it 'throws an error when the file is not found' do - file_path = 'file/not/found' - - expect do - run_described_fastlane_action( - public_version_xcconfig_file: file_path - ) - end.to raise_error(FastlaneCore::Interface::FastlaneError) - end - - it "throws an error when there isn't a version configured in the .xcconfig file" do - xcconfig_mock_content = <<~CONTENT - VERSION_SHORT = 6 - // a comment - CONTENT - - expect do - expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: 'n/a') - end.to raise_error(FastlaneCore::Interface::FastlaneError) - end - - def expect_version(xcconfig_mock_content:, expected_version:) - with_tmp_file(named: 'mock_xcconfig.xcconfig', content: xcconfig_mock_content) do |tmp_file_path| - version_result = run_described_fastlane_action( - public_version_xcconfig_file: tmp_file_path - ) - - expect(version_result).to eq(expected_version) - end - end - end -end diff --git a/spec/ios_get_build_number_spec.rb b/spec/ios_get_build_number_spec.rb deleted file mode 100644 index dadba9c8d..000000000 --- a/spec/ios_get_build_number_spec.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'spec_helper' - -describe Fastlane::Actions::IosGetBuildNumberAction do - describe 'getting the build number from the provided .xcconfig file' do - it 'parses an xcconfig file with keys without spacing and returns the correct build number' do - xcconfig_mock_content = <<~CONTENT - // a comment - VERSION_SHORT=6 - VERSION_LONG=6.30.0 - BUILD_NUMBER=1940 - CONTENT - - expect_build_number(xcconfig_mock_content: xcconfig_mock_content, expected_build_number: '1940') - end - - it 'parses an xcconfig file with keys with spaces and returns the correct build number' do - xcconfig_mock_content = <<~CONTENT - VERSION_SHORT = 6 - VERSION_LONG = 6.30.1 - BUILD_NUMBER = 1940 - CONTENT - - expect_build_number(xcconfig_mock_content: xcconfig_mock_content, expected_build_number: '1940') - end - - it 'parses an xcconfig file with an invalid format and returns a nil build number' do - xcconfig_mock_content = <<~CONTENT - VERSION_SHORT = 6 - VERSION_LONG = 6.30.1 - BUILD_NUMBER 1940 - CONTENT - - expect_build_number(xcconfig_mock_content: xcconfig_mock_content, expected_build_number: nil) - end - - it 'parses an xcconfig file with no build number and returns a nil build number' do - xcconfig_mock_content = <<~CONTENT - VERSION_SHORT = 6 - // a comment - CONTENT - - expect_build_number(xcconfig_mock_content: xcconfig_mock_content, expected_build_number: nil) - end - - it 'throws an error when the xcconfig file does not exist' do - expect do - run_described_fastlane_action( - xcconfig_file_path: 'file/not/found' - ) - end.to raise_error(FastlaneCore::Interface::FastlaneError) - end - - def expect_build_number(xcconfig_mock_content:, expected_build_number:) - with_tmp_file(named: 'mock_xcconfig.xcconfig', content: xcconfig_mock_content) do |tmp_file_path| - build_number_result = run_described_fastlane_action( - xcconfig_file_path: tmp_file_path - ) - - expect(build_number_result).to eq(expected_build_number) - end - end - end -end From d557d470b6af204b936fdfac83c8a93e7f56f479 Mon Sep 17 00:00:00 2001 From: Spencer Transier Date: Sat, 31 Aug 2024 00:27:54 -0700 Subject: [PATCH 2/2] Update CHANGELOG and MIGRATION --- CHANGELOG.md | 8 +++++++- MIGRATION.md | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c71ff72ef..c3b2428e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ - Removed `build_gradle_path` parameter from `android_current_branch_is_hotfix` [#579] - Deleted `Fastlane::Helper::Android::GitHelper` and `Fastlane::Helper::Ios::GitHelper` [#579] -- Deleted the following deprecated actions: [#577, #579] +- Deleted the following deprecated actions: [#577, #579, #586] - `android_betabuild_prechecks` - `android_build_prechecks` - `android_bump_version_beta` @@ -30,8 +30,14 @@ - `ios_bump_version_release` - `ios_codefreeze_prechecks` - `ios_completecodefreeze_prechecks` + - `ios_current_branch_is_hotfix` - `ios_finalize_prechecks` + - `ios_get_app_version` + - `ios_get_build_number` + - `ios_get_build_version` - `ios_hotfix_prechecks` + - `ios_tag_build` + - `ios_validate_ci_build` ### New Features diff --git a/MIGRATION.md b/MIGRATION.md index d99cd3748..1e8af362f 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -5,7 +5,7 @@ - `android_current_branch_is_hotfix` no longer supports the `build_gradle_path` parameter. Convert the project to define `versionName` and `versionCode` in `version.properties` and call `android_current_branch_is_hotfix` with `version_properties_path`. - Various helper methods and actions to calculate version bumps have been deleted (see `CHANGELOG.md` for the full list). Use the `Versioning` module for any version computation or automation. - `Fastlane::Helper:Android::GitHelper` and `Fastlane::Helper::Ios::GitHelper` have been removed. If you were using their respective `commit_version_bump` methods, you'll need to run the commit directly in your `Fastfile`, for example via Fastlane's `git_commit` action. -- `android_tag_build` has been removed. Our recommended workflow for tagging releases relies on GitHub creating a tag when a GitHub release is published. +- `android_tag_build` and `ios_tag_build` have been removed. Our recommended workflow for tagging releases relies on GitHub creating a tag when a GitHub release is published. ## From `10.0.0` to `11.0.0`