From 3a29939288690aee6426defa2b9a9ff2bc612729 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 2 Jun 2022 14:35:09 +1000 Subject: [PATCH 01/28] Remove legacy iOS localization actions and related helpers We now have newer, better actions to achieve the same results: - `ios_generate_strings_file_from_code` - `ios_extract_keys_from_strings_files` - `ios_download_strings_files_from_glotpress` - `ios_merge_strings_files` --- .../actions/ios/ios_localize_project.rb | 43 ------------------- .../actions/ios/ios_update_metadata.rb | 40 ----------------- .../helper/ios/ios_git_helper.rb | 42 ------------------ 3 files changed, 125 deletions(-) delete mode 100644 lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb delete mode 100644 lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata.rb diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb deleted file mode 100644 index 4c30e07c3..000000000 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb +++ /dev/null @@ -1,43 +0,0 @@ -module Fastlane - module Actions - class IosLocalizeProjectAction < Action - def self.run(params) - UI.message 'Updating project localisation...' - - require_relative '../../helper/ios/ios_git_helper' - other_action.cocoapods() - Fastlane::Helper::Ios::GitHelper.localize_project() - - UI.message 'Done.' - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - 'Gathers the strings to localise. Deprecated' - end - - def self.details - 'Gathers the strings to localise. Deprecated in favor of the new `ios_generate_strings_file_from_code`' - end - - def self.category - :deprecated - end - - def self.deprecated_notes - 'This action is deprecated in favor of `ios_generate_strings_file_from_code`' - end - - def self.authors - ['Automattic'] - end - - def self.is_supported?(platform) - platform == :ios - end - end - end -end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata.rb deleted file mode 100644 index 996671246..000000000 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata.rb +++ /dev/null @@ -1,40 +0,0 @@ -module Fastlane - module Actions - class IosUpdateMetadataAction < Action - def self.run(params) - require_relative '../../helper/ios/ios_git_helper' - - Fastlane::Helper::Ios::GitHelper.update_metadata() - end - - ##################################################### - # @!group Documentation - ##################################################### - - def self.description - 'Downloads translated metadata from the translation system' - end - - def self.details - 'Downloads translated metadata from the translation system' - 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) - [:ios, :mac].include?(platform) - end - end - end -end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb index 01909b8c1..77cdc1d2f 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb @@ -28,48 +28,6 @@ def self.commit_version_bump(include_deliverfile: true, include_metadata: true) Fastlane::Helper::GitHelper.commit(message: 'Bump version number', files: files_list, push: true) end - # Calls the `Scripts/localize.py` script in the project root folder and push the `*.strings` files - # - # That script updates the `.strings` files with translations from GlotPress. - # - # @env PROJECT_ROOT_FOLDER The path to the git root of the project - # @env PROJECT_NAME The name of the directory containing the project code (especially containing the `build.gradle` file) - # - # @deprecated This method is only used by the `ios_localize_project` action, which is itself deprecated - # in favor of the new `ios_generate_strings_file_from_code` action - # @todo [Next Major] Remove this method once we fully remove `ios_localize_project` - # - def self.localize_project - Action.sh("cd #{get_from_env!(key: 'PROJECT_ROOT_FOLDER')} && ./Scripts/localize.py") - - Fastlane::Helper::GitHelper.commit(message: 'Update strings for localization', files: strings_files, push: true) || UI.message('No new strings, skipping commit') - end - - # Call the `Scripts/update-translations.rb` then the `fastlane/download_metadata` Scripts from the host project folder - # - # @env PROJECT_ROOT_FOLDER The path to the git root of the project - # @env PROJECT_NAME The name of the directory containing the project code (especially containing the `build.gradle` file) - # - # @todo Migrate the scripts, currently in each host repo and called by this method, to be helpers and actions - # in the release-toolkit instead, and move this code away from `ios_git_helper`. - # - def self.update_metadata - Action.sh("cd #{get_from_env!(key: 'PROJECT_ROOT_FOLDER')} && ./Scripts/update-translations.rb") - - Fastlane::Helper::GitHelper.commit(message: 'Update translations', files: strings_files, push: false) - - Action.sh('cd fastlane && ./download_metadata.swift') - - Fastlane::Helper::GitHelper.commit(message: 'Update metadata translations', files: './fastlane/metadata/', push: true) - end - - def self.strings_files - project_root = get_from_env!(key: 'PROJECT_ROOT_FOLDER') - project_name = get_from_env!(key: 'PROJECT_NAME') - - Dir.glob(File.join(project_root, project_name, '**', '*.strings')) - end - def self.get_from_env!(key:) ENV.fetch(key) do UI.user_error! "Could not find value for \"#{key}\" in environment." From 0a769a747d9a09659da5186e90e4e2ddbaa19ac6 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Tue, 24 Jan 2023 23:44:27 +0100 Subject: [PATCH 02/28] Remove download_metadata.swift references --- .../actions/ios/ios_bump_version_beta.rb | 2 +- .../actions/ios/ios_bump_version_hotfix.rb | 2 +- .../actions/ios/ios_bump_version_release.rb | 3 +-- .../wpmreleasetoolkit/helper/ios/ios_git_helper.rb | 9 +-------- spec/ios_bump_version_release_spec.rb | 4 ++-- 5 files changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb index f6228c9f9..3d91cbd07 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb @@ -15,7 +15,7 @@ def self.run(params) Fastlane::Helper::Ios::VersionHelper.update_xc_configs(@new_beta_version, @short_version, @new_internal_version) UI.message 'Done!' - Fastlane::Helper::Ios::GitHelper.commit_version_bump(include_deliverfile: false, include_metadata: false) + Fastlane::Helper::Ios::GitHelper.commit_version_bump(include_deliverfile: false) end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb index aa6ff18dc..1774ba4fa 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb @@ -20,7 +20,7 @@ def self.run(params) Fastlane::Helper::Ios::VersionHelper.update_xc_configs(@new_version, @new_short_version, @new_version_internal) UI.message 'Done!' - Fastlane::Helper::Ios::GitHelper.commit_version_bump(include_deliverfile: update_deliverfile, include_metadata: false) + Fastlane::Helper::Ios::GitHelper.commit_version_bump(include_deliverfile: update_deliverfile) UI.message 'Done.' end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb index 2cddf478f..986c037f7 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb @@ -30,8 +30,7 @@ def self.run(params) UI.message 'Done!' Fastlane::Helper::Ios::GitHelper.commit_version_bump( - include_deliverfile: !params[:skip_deliver], - include_metadata: false + include_deliverfile: !params[:skip_deliver] ) UI.message 'Done.' diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb index 77cdc1d2f..162a01638 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb @@ -9,21 +9,14 @@ module GitHelper # This typically commits and pushes: # - The files in `./config/*` – especially `Version.*.xcconfig` files # - The `fastlane/Deliverfile` file (which contains the `app_version` line) - # - The `//Resources/AppStoreStrings.pot` file, containing a key for that version's release notes # # @env PROJECT_ROOT_FOLDER The path to the git root of the project - # @env PROJECT_NAME The name of the directory containing the project code (especially containing the Resources/ subfolder) # # @param [Bool] include_deliverfile If true (the default), includes the `fastlane/Deliverfile` in files being commited - # @param [Bool] include_metadata If true (the default), includes the `fastlane/download_metadata.swift` file and the `.pot` file (which typically contains an entry or release notes for the new version) # - def self.commit_version_bump(include_deliverfile: true, include_metadata: true) + def self.commit_version_bump(include_deliverfile: true) files_list = [File.join(ENV['PROJECT_ROOT_FOLDER'], 'config', '.')] files_list.append File.join('fastlane', 'Deliverfile') if include_deliverfile - if include_metadata - files_list.append File.join('fastlane', 'download_metadata.swift') - files_list.append File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'Resources', ENV['APP_STORE_STRINGS_FILE_NAME']) - end Fastlane::Helper::GitHelper.commit(message: 'Bump version number', files: files_list, push: true) end diff --git a/spec/ios_bump_version_release_spec.rb b/spec/ios_bump_version_release_spec.rb index f2a3f882e..70d8bdea9 100644 --- a/spec/ios_bump_version_release_spec.rb +++ b/spec/ios_bump_version_release_spec.rb @@ -23,7 +23,7 @@ skip_deliver = false expect(Fastlane::Helper::Ios::VersionHelper).to receive(:update_fastlane_deliver).with(next_version_short) - expect(Fastlane::Helper::Ios::GitHelper).to receive(:commit_version_bump).with(include_deliverfile: !skip_deliver, include_metadata: false) + expect(Fastlane::Helper::Ios::GitHelper).to receive(:commit_version_bump).with(include_deliverfile: !skip_deliver) run_described_fastlane_action( skip_deliver: skip_deliver, @@ -35,7 +35,7 @@ skip_deliver = true expect(Fastlane::Helper::Ios::VersionHelper).not_to receive(:update_fastlane_deliver) - expect(Fastlane::Helper::Ios::GitHelper).to receive(:commit_version_bump).with(include_deliverfile: !skip_deliver, include_metadata: false) + expect(Fastlane::Helper::Ios::GitHelper).to receive(:commit_version_bump).with(include_deliverfile: !skip_deliver) run_described_fastlane_action( skip_deliver: skip_deliver, From 69f5e039736ec9e4bb41c9f1d2d3440509a71f7e Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Sun, 29 Jan 2023 19:32:07 +0100 Subject: [PATCH 03/28] Use get_from_env util method instead of accessing environment var directly --- .../plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb index 162a01638..d37dc3310 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb @@ -15,7 +15,7 @@ module GitHelper # @param [Bool] include_deliverfile If true (the default), includes the `fastlane/Deliverfile` in files being commited # def self.commit_version_bump(include_deliverfile: true) - files_list = [File.join(ENV['PROJECT_ROOT_FOLDER'], 'config', '.')] + files_list = [File.join(get_from_env!(key: 'PROJECT_ROOT_FOLDER'), 'config', '.')] files_list.append File.join('fastlane', 'Deliverfile') if include_deliverfile Fastlane::Helper::GitHelper.commit(message: 'Bump version number', files: files_list, push: true) From 89616449e55fbbbcdaf1bbd2a601228133b1444c Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Mon, 30 Jan 2023 00:28:30 +0100 Subject: [PATCH 04/28] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22075a2d7..a83dc055d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Breaking Changes - Remove the `skip_glotpress` parameter from the `ios_bump_version_release` action [#443] +- Remove the actions `ios_localize_project` and `ios_update_metadata` ### New Features From c48d444da9ca151e49daad0258262983b16ba3de Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Mon, 30 Jan 2023 22:29:49 +0100 Subject: [PATCH 05/28] Add PR reference to changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a83dc055d..459e9f24c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ ### Breaking Changes - Remove the `skip_glotpress` parameter from the `ios_bump_version_release` action [#443] -- Remove the actions `ios_localize_project` and `ios_update_metadata` +- Remove the actions `ios_localize_project` and `ios_update_metadata` [#447] ### New Features From 7aaa3b7dccb394baad96761ebd856303086a52af Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Tue, 31 Jan 2023 23:52:06 +0100 Subject: [PATCH 06/28] 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 459e9f24c..6e93b5385 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ ### Breaking Changes - Remove the `skip_glotpress` parameter from the `ios_bump_version_release` action [#443] -- Remove the actions `ios_localize_project` and `ios_update_metadata` [#447] +- Remove the `ios_localize_project` and `ios_update_metadata` actions [#447] ### New Features From 476cf80b89d6b20e1dffc13bc3633bb3517d82b2 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Thu, 26 Jan 2023 01:09:29 +0100 Subject: [PATCH 07/28] Add ConfigItem for .xcconfig to replace env var on ios_get_app_version --- .../actions/ios/ios_get_app_version.rb | 15 +++++-- .../helper/ios/ios_version_helper.rb | 42 ++++++++++--------- 2 files changed, 34 insertions(+), 23 deletions(-) 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 index 8d2a647be..89c343229 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb @@ -4,9 +4,8 @@ class IosGetAppVersionAction < 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'] - - Fastlane::Helper::Ios::VersionHelper.get_public_version + public_version_xcconfig_file = params[:public_version_xcconfig_file] + Fastlane::Helper::Ios::VersionHelper.get_xcconfig_public_version(xcconfig_file: public_version_xcconfig_file) end ##################################################### @@ -22,7 +21,15 @@ def self.details end def self.available_options - # Define all options your action supports. + [ + FastlaneCore::ConfigItem.new( + key: :public_version_xcconfig_file, + env_name: 'FL_IOS_GET_APP_VERSION_PUBLIC_VERSION_XCCONFIG_FILE', + description: 'Path to the .xcconfig file containing the public app version', + type: String, + optional: false + ), + ] end def self.output 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 16059c4b4..dd98e2962 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb @@ -15,12 +15,30 @@ module VersionHelper # 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) + 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 + version = get_build_version() vp = get_version_parts(version) return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" unless is_hotfix?(version) @@ -169,7 +187,8 @@ def self.is_hotfix?(version) # @return [String] The current version according to the public xcconfig file. # def self.get_build_version - versions = get_version_strings()[0] + 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 @@ -177,7 +196,8 @@ def self.get_build_version # @return [String] The current version according to the internal xcconfig file. # def self.get_internal_version - get_version_strings()[1] + 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 @@ -301,22 +321,6 @@ def self.read_from_config_file(key, filePath) return nil end - # Read the version numbers from the xcconfig file - # - # @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. - # - # @return [String] Array of long version strings found. - # The first element is always present and contains the version extracted from the public config file - # The second element is the version extracted from the internal config file, only present if one was provided. - def self.get_version_strings - version_strings = [] - version_strings << read_long_version_from_config_file(ENV['PUBLIC_CONFIG_FILE']) - version_strings << read_long_version_from_config_file(ENV['INTERNAL_CONFIG_FILE']) unless ENV['INTERNAL_CONFIG_FILE'].nil? - - return version_strings - 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 From 9add5bf1bb800b4b0f812d443d843bcf51bbe34b Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Fri, 27 Jan 2023 20:12:37 +0100 Subject: [PATCH 08/28] Add unit tests for the ios_get_app_version action --- spec/ios_get_app_version_spec.rb | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 spec/ios_get_app_version_spec.rb diff --git a/spec/ios_get_app_version_spec.rb b/spec/ios_get_app_version_spec.rb new file mode 100644 index 000000000..2e4334d74 --- /dev/null +++ b/spec/ios_get_app_version_spec.rb @@ -0,0 +1,41 @@ +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 + + allow(File).to receive(:exist?).and_return(true) + + 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 + + allow(File).to receive(:exist?).and_return(true) + + expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30.1') + end + + def expect_version(xcconfig_mock_content:, expected_version:) + xcconfig_mock_file_path = File.join('mock', 'file', 'path') + + allow(File).to receive(:open).with(xcconfig_mock_file_path, 'r').and_yield(StringIO.new(xcconfig_mock_content)) + + version_result = run_described_fastlane_action( + public_version_xcconfig_file: xcconfig_mock_file_path + ) + + expect(version_result).to eq(expected_version) + end + end +end From c1bb8a469167015a476135bc73144c8b16599cfc Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Fri, 27 Jan 2023 21:16:15 +0100 Subject: [PATCH 09/28] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e7507de4..e9140abad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ ### Breaking Changes - Remove the `skip_glotpress` parameter from the `ios_bump_version_release` action [#443] +- Add the `public_version_xcconfig_file` parameter to the `ios_get_app_version` action to replace the need for an environment variable [#445] - Remove the `ios_localize_project` and `ios_update_metadata` actions [#447] ### New Features From 60a350cb4b5abf5ab331829dba650366e4e614ad Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Wed, 1 Feb 2023 16:40:05 +0100 Subject: [PATCH 10/28] Fix unit test that broke due changes in `Ios::VersionHelper` --- spec/ios_bump_version_release_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/ios_bump_version_release_spec.rb b/spec/ios_bump_version_release_spec.rb index 70d8bdea9..421158e5b 100644 --- a/spec/ios_bump_version_release_spec.rb +++ b/spec/ios_bump_version_release_spec.rb @@ -2,7 +2,7 @@ describe Fastlane::Actions::IosBumpVersionReleaseAction do let(:default_branch) { 'my_new_branch' } - let(:versions) { ['6.30'] } + let(:version) { '6.30' } let(:next_version) { '6.31.0.0' } let(:next_version_short) { '6.31' } @@ -15,7 +15,7 @@ allow(Fastlane::Helper::GitHelper).to receive(:checkout_and_pull).with(default_branch) allow(Fastlane::Helper::GitHelper).to receive(:create_branch).with("release/#{next_version_short}", from: default_branch) - allow(Fastlane::Helper::Ios::VersionHelper).to receive(:get_version_strings).and_return(versions) + allow(Fastlane::Helper::Ios::VersionHelper).to receive(:read_from_config_file).and_return(version) allow(Fastlane::Helper::Ios::VersionHelper).to receive(:update_xc_configs).with(next_version, next_version_short, nil) end From fce43b38be285f0b87650fe46df88ab8f463ca1f Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Wed, 1 Feb 2023 16:47:28 +0100 Subject: [PATCH 11/28] Change `ios_get_app_version` environment var to a more generic one, so that the same name can be reused across actions --- .../plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 89c343229..e08aa40fb 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb @@ -24,7 +24,7 @@ def self.available_options [ FastlaneCore::ConfigItem.new( key: :public_version_xcconfig_file, - env_name: 'FL_IOS_GET_APP_VERSION_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 From fd93d892d536810deeec394bb66d72cff3edfeaf Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Fri, 27 Jan 2023 20:44:36 +0100 Subject: [PATCH 12/28] Improve the version parsing code to better handle error cases --- .../helper/ios/ios_version_helper.rb | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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 dd98e2962..05a78cd74 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb @@ -23,6 +23,9 @@ module VersionHelper # 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) @@ -306,15 +309,22 @@ def self.read_build_number_from_config_file(filePath) # Read the value of a given key from an `.xcconfig` file. # # @param [String] key The xcconfig key to get the value for - # @param [String] filePath The path to the `.xcconfig` file to read the value from + # @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, filePath) - File.open(filePath, 'r') do |f| + def self.read_from_config_file(key, file_path) + UI.user_error!("File #{file_path} not found") unless File.exist?(file_path) + + File.open(file_path, 'r') do |f| f.each_line do |line| - line = line.strip() - return line.split('=')[1] if line.start_with?("#{key}=") + line.strip! + next if line.nil? || line.empty? + + key_value = line.split(/\s*=\s*/) + if key_value[0].strip() == key + return key_value[1].strip() + end end end From 47ac3f987c805394e2e4ccb7a76111575a951b8b Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Fri, 27 Jan 2023 20:45:31 +0100 Subject: [PATCH 13/28] Add unit tests for ios_get_app_version error cases --- spec/ios_get_app_version_spec.rb | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/spec/ios_get_app_version_spec.rb b/spec/ios_get_app_version_spec.rb index 2e4334d74..ae9f7b834 100644 --- a/spec/ios_get_app_version_spec.rb +++ b/spec/ios_get_app_version_spec.rb @@ -5,8 +5,8 @@ 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 + VERSION_SHORT = 6 + VERSION_LONG = 6.30.0 CONTENT allow(File).to receive(:exist?).and_return(true) @@ -16,9 +16,9 @@ it 'parses the xcconfig file format correctly and gets the public hotfix version' do xcconfig_mock_content = <<~CONTENT - VERSION_SHORT=6 + VERSION_SHORT = 6 // a comment - VERSION_LONG=6.30.1 + VERSION_LONG = 6.30.1 CONTENT allow(File).to receive(:exist?).and_return(true) @@ -26,6 +26,29 @@ expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30.1') 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 + + allow(File).to receive(:exist?).and_return(true) + + 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:) xcconfig_mock_file_path = File.join('mock', 'file', 'path') From a1d8dc9c89de0883aeff8f4542a1372fc451e07b Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Wed, 1 Feb 2023 18:02:00 +0100 Subject: [PATCH 14/28] Make ios_get_app_version_spec unit tests to work with an actual file to avoid relying on implementation details --- spec/ios_get_app_version_spec.rb | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/spec/ios_get_app_version_spec.rb b/spec/ios_get_app_version_spec.rb index ae9f7b834..bf3a63636 100644 --- a/spec/ios_get_app_version_spec.rb +++ b/spec/ios_get_app_version_spec.rb @@ -9,8 +9,6 @@ VERSION_LONG = 6.30.0 CONTENT - allow(File).to receive(:exist?).and_return(true) - expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30') end @@ -21,8 +19,6 @@ VERSION_LONG = 6.30.1 CONTENT - allow(File).to receive(:exist?).and_return(true) - expect_version(xcconfig_mock_content: xcconfig_mock_content, expected_version: '6.30.1') end @@ -42,23 +38,21 @@ // a comment CONTENT - allow(File).to receive(:exist?).and_return(true) - 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:) - xcconfig_mock_file_path = File.join('mock', 'file', 'path') - - allow(File).to receive(:open).with(xcconfig_mock_file_path, 'r').and_yield(StringIO.new(xcconfig_mock_content)) + allow(File).to receive(:exist?).and_return(true) - version_result = run_described_fastlane_action( - public_version_xcconfig_file: xcconfig_mock_file_path - ) + 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) + expect(version_result).to eq(expected_version) + end end end end From 7365a2fb84693f3796da7a4ae73f4689b21134f0 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Wed, 1 Feb 2023 18:04:13 +0100 Subject: [PATCH 15/28] Improve method to read .xcconfig file to use Xcodeproj::Config instead of manually parsing it --- .../helper/ios/ios_version_helper.rb | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) 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 05a78cd74..8866e111b 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb @@ -1,3 +1,5 @@ +require 'xcodeproj' + module Fastlane module Helper module Ios @@ -314,21 +316,10 @@ def self.read_build_number_from_config_file(filePath) # @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!("File #{file_path} not found") unless File.exist?(file_path) - - File.open(file_path, 'r') do |f| - f.each_line do |line| - line.strip! - next if line.nil? || line.empty? - - key_value = line.split(/\s*=\s*/) - if key_value[0].strip() == key - return key_value[1].strip() - end - end - end + UI.user_error!(".xcconfig file #{file_path} not found") unless File.exist?(file_path) - return nil + 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 From 9a84d8e275cd049091053c026a651b8d4383eb72 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Fri, 3 Feb 2023 21:56:03 +0100 Subject: [PATCH 16/28] Add explicit dependency to xcodeproj --- Gemfile.lock | 1 + fastlane-plugin-wpmreleasetoolkit.gemspec | 1 + 2 files changed, 2 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index e25104bc0..4d0a2294d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,6 +16,7 @@ PATH progress_bar (~> 1.3) rake (>= 12.3, < 14.0) rake-compiler (~> 1.0) + xcodeproj (~> 1.22.0) GEM remote: https://rubygems.org/ diff --git a/fastlane-plugin-wpmreleasetoolkit.gemspec b/fastlane-plugin-wpmreleasetoolkit.gemspec index 3266d5cbd..23621b0b4 100644 --- a/fastlane-plugin-wpmreleasetoolkit.gemspec +++ b/fastlane-plugin-wpmreleasetoolkit.gemspec @@ -37,6 +37,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'progress_bar', '~> 1.3' spec.add_dependency 'rake', '>= 12.3', '< 14.0' spec.add_dependency 'rake-compiler', '~> 1.0' + spec.add_dependency 'xcodeproj', '~> 1.22.0' # `google-cloud-storage` is required by fastlane, but we pin it in case it's not in the future spec.add_dependency 'google-cloud-storage', '~> 1.31' From 2c097ebe08f9d760311a7448ab0e38123a79d5ea Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Fri, 3 Feb 2023 21:56:23 +0100 Subject: [PATCH 17/28] Remove unnecessary mock of File existence check --- spec/ios_get_app_version_spec.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/spec/ios_get_app_version_spec.rb b/spec/ios_get_app_version_spec.rb index bf3a63636..8b781b9f9 100644 --- a/spec/ios_get_app_version_spec.rb +++ b/spec/ios_get_app_version_spec.rb @@ -44,8 +44,6 @@ end def expect_version(xcconfig_mock_content:, expected_version:) - allow(File).to receive(:exist?).and_return(true) - 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 From ef6faabacf9d8e3fe9a1ad1c4c78c8c67d3506ab Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Fri, 3 Feb 2023 21:58:26 +0100 Subject: [PATCH 18/28] Add more test cases for different .xcconfig file formats --- spec/ios_get_app_version_spec.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/spec/ios_get_app_version_spec.rb b/spec/ios_get_app_version_spec.rb index 8b781b9f9..0355fd175 100644 --- a/spec/ios_get_app_version_spec.rb +++ b/spec/ios_get_app_version_spec.rb @@ -22,6 +22,37 @@ 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' From 2aef505e9ac84bf05af9cf7f44ea7ec80915f6ef Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Sat, 4 Feb 2023 20:20:56 +0100 Subject: [PATCH 19/28] Fix dependency to xcodeproj to allow for minor updates --- Gemfile.lock | 2 +- fastlane-plugin-wpmreleasetoolkit.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4d0a2294d..df251f5e0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,7 +16,7 @@ PATH progress_bar (~> 1.3) rake (>= 12.3, < 14.0) rake-compiler (~> 1.0) - xcodeproj (~> 1.22.0) + xcodeproj (~> 1.22) GEM remote: https://rubygems.org/ diff --git a/fastlane-plugin-wpmreleasetoolkit.gemspec b/fastlane-plugin-wpmreleasetoolkit.gemspec index 23621b0b4..3e67c9591 100644 --- a/fastlane-plugin-wpmreleasetoolkit.gemspec +++ b/fastlane-plugin-wpmreleasetoolkit.gemspec @@ -37,7 +37,7 @@ Gem::Specification.new do |spec| spec.add_dependency 'progress_bar', '~> 1.3' spec.add_dependency 'rake', '>= 12.3', '< 14.0' spec.add_dependency 'rake-compiler', '~> 1.0' - spec.add_dependency 'xcodeproj', '~> 1.22.0' + spec.add_dependency 'xcodeproj', '~> 1.22' # `google-cloud-storage` is required by fastlane, but we pin it in case it's not in the future spec.add_dependency 'google-cloud-storage', '~> 1.31' From 4c5b4a1e19b60838a290db3fb3fc673747f7a6ee Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Sun, 29 Jan 2023 21:04:17 +0100 Subject: [PATCH 20/28] Remove Deliverfile related functionality and references --- .../actions/ios/ios_bump_version_beta.rb | 2 +- .../actions/ios/ios_bump_version_hotfix.rb | 19 +------------ .../actions/ios/ios_bump_version_release.rb | 13 +-------- .../helper/ios/ios_git_helper.rb | 6 +---- .../helper/ios/ios_version_helper.rb | 14 ---------- spec/ios_bump_version_release_spec.rb | 27 ++++--------------- 6 files changed, 9 insertions(+), 72 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb index 3d91cbd07..36016085a 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb @@ -15,7 +15,7 @@ def self.run(params) Fastlane::Helper::Ios::VersionHelper.update_xc_configs(@new_beta_version, @short_version, @new_internal_version) UI.message 'Done!' - Fastlane::Helper::Ios::GitHelper.commit_version_bump(include_deliverfile: false) + Fastlane::Helper::Ios::GitHelper.commit_version_bump() end ##################################################### diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb index 1774ba4fa..71cabe795 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb @@ -9,18 +9,11 @@ def self.run(params) create_config(params[:previous_version], params[:version]) show_config() - update_deliverfile = params[:skip_deliver] == false - if update_deliverfile - UI.message 'Updating Fastlane deliver file...' - Fastlane::Helper::Ios::VersionHelper.update_fastlane_deliver(@new_short_version) - UI.message 'Done!' - end - UI.message 'Updating XcConfig...' Fastlane::Helper::Ios::VersionHelper.update_xc_configs(@new_version, @new_short_version, @new_version_internal) UI.message 'Done!' - Fastlane::Helper::Ios::GitHelper.commit_version_bump(include_deliverfile: update_deliverfile) + Fastlane::Helper::Ios::GitHelper.commit_version_bump() UI.message 'Done.' end @@ -51,16 +44,6 @@ def self.available_options description: 'The version to branch from', is_string: true ), - FastlaneCore::ConfigItem.new( - key: :skip_deliver, - env_name: 'FL_IOS_BUMP_VERSION_HOTFIX_SKIP_DELIVER', - description: 'Skips Deliverfile key update', - is_string: false, # Boolean parameter - optional: true, - # Don't skip the Deliverfile by default. At the time of writing, 2 out of 3 consumers - # still have a Deliverfile. - default_value: false - ), ] end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb index 986c037f7..0f71931ce 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb @@ -21,17 +21,11 @@ def self.run(params) Fastlane::Helper::GitHelper.create_branch(@new_release_branch, from: default_branch) UI.message 'Done!' - UI.message 'Updating Fastlane deliver file...' unless params[:skip_deliver] - Fastlane::Helper::Ios::VersionHelper.update_fastlane_deliver(@new_short_version) unless params[:skip_deliver] - UI.message 'Done!' unless params[:skip_deliver] - UI.message 'Updating XcConfig...' Fastlane::Helper::Ios::VersionHelper.update_xc_configs(@new_version, @new_short_version, @new_version_internal) UI.message 'Done!' - Fastlane::Helper::Ios::GitHelper.commit_version_bump( - include_deliverfile: !params[:skip_deliver] - ) + Fastlane::Helper::Ios::GitHelper.commit_version_bump() UI.message 'Done.' end @@ -50,11 +44,6 @@ def self.details def self.available_options [ - FastlaneCore::ConfigItem.new(key: :skip_deliver, - env_name: 'FL_IOS_CODEFREEZE_BUMP_SKIPDELIVER', - description: 'Skips Deliver key update', - type: Boolean, - default_value: false), FastlaneCore::ConfigItem.new(key: :default_branch, env_name: 'FL_RELEASE_TOOLKIT_DEFAULT_BRANCH', description: 'Default branch of the repository', diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb index d37dc3310..659ffc27d 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb @@ -8,15 +8,11 @@ module GitHelper # # This typically commits and pushes: # - The files in `./config/*` – especially `Version.*.xcconfig` files - # - The `fastlane/Deliverfile` file (which contains the `app_version` line) # # @env PROJECT_ROOT_FOLDER The path to the git root of the project # - # @param [Bool] include_deliverfile If true (the default), includes the `fastlane/Deliverfile` in files being commited - # - def self.commit_version_bump(include_deliverfile: true) + def self.commit_version_bump files_list = [File.join(get_from_env!(key: 'PROJECT_ROOT_FOLDER'), 'config', '.')] - files_list.append File.join('fastlane', 'Deliverfile') if include_deliverfile Fastlane::Helper::GitHelper.commit(message: 'Bump version number', files: files_list, push: true) end 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 dd98e2962..b1d7f2e4a 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb @@ -215,20 +215,6 @@ def self.bump_version_release return verified_version end - # Updates the `app_version` entry in the `Deliverfile` - # - # @param [String] new_version The new value to set the `app_version` entry to. - # @raise [UserError] If the Deliverfile was not found. - # - def self.update_fastlane_deliver(new_version) - fd_file = './fastlane/Deliverfile' - if File.exist?(fd_file) - Action.sh("sed -i '' \"s/app_version.*/app_version \\\"#{new_version}\\\"/\" #{fd_file}") - else - UI.user_error!("Can't find #{fd_file}.") - end - 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. diff --git a/spec/ios_bump_version_release_spec.rb b/spec/ios_bump_version_release_spec.rb index 421158e5b..10089ba72 100644 --- a/spec/ios_bump_version_release_spec.rb +++ b/spec/ios_bump_version_release_spec.rb @@ -11,34 +11,17 @@ other_action_mock = double() allow(Fastlane::Action).to receive(:other_action).and_return(other_action_mock) allow(other_action_mock).to receive(:ensure_git_branch).with(branch: default_branch) - - allow(Fastlane::Helper::GitHelper).to receive(:checkout_and_pull).with(default_branch) - allow(Fastlane::Helper::GitHelper).to receive(:create_branch).with("release/#{next_version_short}", from: default_branch) - allow(Fastlane::Helper::Ios::VersionHelper).to receive(:read_from_config_file).and_return(version) - allow(Fastlane::Helper::Ios::VersionHelper).to receive(:update_xc_configs).with(next_version, next_version_short, nil) - end - - it 'does the fastlane deliver update' do - skip_deliver = false - - expect(Fastlane::Helper::Ios::VersionHelper).to receive(:update_fastlane_deliver).with(next_version_short) - expect(Fastlane::Helper::Ios::GitHelper).to receive(:commit_version_bump).with(include_deliverfile: !skip_deliver) - - run_described_fastlane_action( - skip_deliver: skip_deliver, - default_branch: default_branch - ) end - it 'skips the fastlane deliver update properly' do - skip_deliver = true + it 'correctly uses the next version, short and long' do + expect(Fastlane::Helper::GitHelper).to receive(:checkout_and_pull).with(default_branch) + expect(Fastlane::Helper::GitHelper).to receive(:create_branch).with("release/#{next_version_short}", from: default_branch) - expect(Fastlane::Helper::Ios::VersionHelper).not_to receive(:update_fastlane_deliver) - expect(Fastlane::Helper::Ios::GitHelper).to receive(:commit_version_bump).with(include_deliverfile: !skip_deliver) + expect(Fastlane::Helper::Ios::VersionHelper).to receive(:update_xc_configs).with(next_version, next_version_short, nil) + expect(Fastlane::Helper::Ios::GitHelper).to receive(:commit_version_bump) run_described_fastlane_action( - skip_deliver: skip_deliver, default_branch: default_branch ) end From 5066134ad0211351252ea51b7262717033f7c5dc Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Mon, 30 Jan 2023 00:24:41 +0100 Subject: [PATCH 21/28] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9140abad..1d229c860 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ - Remove the `skip_glotpress` parameter from the `ios_bump_version_release` action [#443] - Add the `public_version_xcconfig_file` parameter to the `ios_get_app_version` action to replace the need for an environment variable [#445] - Remove the `ios_localize_project` and `ios_update_metadata` actions [#447] +- Remove the `skip_deliver` parameter from the `ios_bump_version_hotfix` action +- Remove the `skip_deliver` parameter from the `ios_bump_version_release` action ### New Features From 5a5b09fdb172092dc8de43b5ed2b607c74178107 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Fri, 10 Feb 2023 19:41:09 +0100 Subject: [PATCH 22/28] Update CHANGELOG.md Co-authored-by: Olivier Halligon --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d229c860..d27004239 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,7 @@ - Remove the `skip_glotpress` parameter from the `ios_bump_version_release` action [#443] - Add the `public_version_xcconfig_file` parameter to the `ios_get_app_version` action to replace the need for an environment variable [#445] - Remove the `ios_localize_project` and `ios_update_metadata` actions [#447] -- Remove the `skip_deliver` parameter from the `ios_bump_version_hotfix` action -- Remove the `skip_deliver` parameter from the `ios_bump_version_release` action +- Remove the `skip_deliver` parameter from `ios_bump_version_hotfix` and `ios_bump_version_release` actions ### New Features From 8eeea6555caae92fd60d9a7ce7a1be4b842e7a08 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Fri, 10 Feb 2023 19:52:50 +0100 Subject: [PATCH 23/28] Update PR reference on change log --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d27004239..8dd9924cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ - Remove the `skip_glotpress` parameter from the `ios_bump_version_release` action [#443] - Add the `public_version_xcconfig_file` parameter to the `ios_get_app_version` action to replace the need for an environment variable [#445] - Remove the `ios_localize_project` and `ios_update_metadata` actions [#447] -- Remove the `skip_deliver` parameter from `ios_bump_version_hotfix` and `ios_bump_version_release` actions +- Remove the `skip_deliver` parameter from `ios_bump_version_hotfix` and `ios_bump_version_release` actions [#450] ### New Features From 4e2cae393878789ac5240c723917c6f75bc83781 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Sat, 11 Feb 2023 16:23:40 +0100 Subject: [PATCH 24/28] Update change log with mention to `xcodeproj` dependency --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9140abad..ddba14f91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ _None_ ### Internal Changes - Updates `activesupport` to `6.1.7.1`, addressing [a security issue](https://github.com/advisories/GHSA-j6gc-792m-qgm2). This is a major version change, but as the dependency is internal-only, it shouldn't be a breaking change for clients. [#441] +- Add the explicit dependency to `xcodeproj (~> 1.22)`, used in this case to replace the previous manual parsing of `.xcconfig` files. [#451] ## 6.3.0 From e647f82d9b0bd5e704037836352c827cfa2c730d Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Sun, 5 Feb 2023 18:52:54 +0100 Subject: [PATCH 25/28] Add migration guide --- MIGRATION.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 MIGRATION.md diff --git a/MIGRATION.md b/MIGRATION.md new file mode 100644 index 000000000..a908138c0 --- /dev/null +++ b/MIGRATION.md @@ -0,0 +1,18 @@ +# Release Toolkit Migration Guide + +--- + +## Migrating to Trunk + +### Considerations for breaking changes + +- Ensure that calls to `ios_bump_version_release` already passed `skip_glotpress: true`. +In case of passing false as parameter or not providing a value (false being the default for this ConfigItem), you'll have to ensure that: + - `download_metadata.swift` isn't being used; if it is, it's a good time to migrate to the new tooling + - You're not relying on `ios_bump_version_release` for commiting the `.po/.pot` file +- The deprecated actions `ios_localize_project` and `ios_update_metadata` were now completely removed. If your project is still using it, please use the new tooling instead. +See `ios_generate_strings_file_from_code`, `ios_extract_keys_from_strings_files`, `ios_download_strings_files_from_glotpress` and `ios_merge_strings_files`. + +### Clean-ups + +- You can now delete the `ENV['APP_STORE_STRINGS_FILE_NAME']` from your Fastfile, as it isn't being used anymore. From 491d83f361173af50e2b113d2642b29e543bce6b Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Fri, 10 Feb 2023 18:24:21 +0100 Subject: [PATCH 26/28] Update MIGRATION.md Co-authored-by: Olivier Halligon --- MIGRATION.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MIGRATION.md b/MIGRATION.md index a908138c0..63bf9b00d 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -10,8 +10,8 @@ In case of passing false as parameter or not providing a value (false being the default for this ConfigItem), you'll have to ensure that: - `download_metadata.swift` isn't being used; if it is, it's a good time to migrate to the new tooling - You're not relying on `ios_bump_version_release` for commiting the `.po/.pot` file -- The deprecated actions `ios_localize_project` and `ios_update_metadata` were now completely removed. If your project is still using it, please use the new tooling instead. -See `ios_generate_strings_file_from_code`, `ios_extract_keys_from_strings_files`, `ios_download_strings_files_from_glotpress` and `ios_merge_strings_files`. +- The deprecated actions `ios_localize_project` and `ios_update_metadata` were now completely removed. If your project is still using them, please use the new tooling instead. + - See `ios_generate_strings_file_from_code`, `ios_extract_keys_from_strings_files`, `ios_download_strings_files_from_glotpress` and `ios_merge_strings_files` for typical replacements. ### Clean-ups From e9ab7c57234ebdbdc20f06bfab7fa63130f68fc9 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Sun, 12 Feb 2023 18:13:01 +0100 Subject: [PATCH 27/28] Add remarks about the migration needs related to the action `ios_get_app_version` and the `Deliverfile` --- MIGRATION.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MIGRATION.md b/MIGRATION.md index 63bf9b00d..784cce6d6 100644 --- a/MIGRATION.md +++ b/MIGRATION.md @@ -12,6 +12,8 @@ In case of passing false as parameter or not providing a value (false being the - You're not relying on `ios_bump_version_release` for commiting the `.po/.pot` file - The deprecated actions `ios_localize_project` and `ios_update_metadata` were now completely removed. If your project is still using them, please use the new tooling instead. - See `ios_generate_strings_file_from_code`, `ios_extract_keys_from_strings_files`, `ios_download_strings_files_from_glotpress` and `ios_merge_strings_files` for typical replacements. +- The action `ios_get_app_version` now requires a parameter `public_version_xcconfig_file` with the public `.xcconfig` file path instead of relying on the environment variable `PUBLIC_CONFIG_FILE`. While the complete removal of this environment variable is our goal, at this point it is still required by other actions such as `ios_bump_version_release` and `ios_codefreeze_prechecks`. +- The usage of a `Deliverfile` (including its `app_version`) is discouraged -- please use `upload_to_app_store` directly from your `Fastfile` instead. Therefore, the parameter `skip_deliver` from the actions `ios_bump_version_hotfix` and `ios_bump_version_release` has been removed. ### Clean-ups From 212bd3a9e5567237baa1c7819021bce4e60ccb19 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Sun, 12 Feb 2023 19:05:40 +0100 Subject: [PATCH 28/28] Update PR template to include a reference to the `MIGRATION.md` file --- .github/PULL_REQUEST_TEMPLATE.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 19b270dd8..63edad33e 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,4 +5,5 @@ - [ ] Run `bundle exec rubocop` to test for code style violations and recommendations - [ ] Add Unit Tests (aka `specs/*_spec.rb`) if applicable - [ ] Run `bundle exec rspec` to run the whole test suite and ensure all your tests pass -- [ ] Make sure you added an entry in [the `CHANGELOG.md` file](https://github.com/wordpress-mobile/release-toolkit/blob/trunk/CHANGELOG.md#trunk) to describe your changes under the approprioate existing `###` subsection of the existing `## Trunk` section. \ No newline at end of file +- [ ] Make sure you added an entry in [the `CHANGELOG.md` file](https://github.com/wordpress-mobile/release-toolkit/blob/trunk/CHANGELOG.md#trunk) to describe your changes under the appropriate existing `###` subsection of the existing `## Trunk` section. +- [ ] If relevant, please add an entry in [the `MIGRATION.md` file](https://github.com/wordpress-mobile/release-toolkit/blob/trunk/MIGRATION.md#migrating-to-trunk) to provide more context for a version migration impacted by the changes in this pull request, in the appropriate `###` subsection of the existing `## Migrating to Trunk` section.