fastlane-plugin-wpmreleasetoolkit 8.1.0 → 9.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb +6 -4
  3. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb +1 -1
  4. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +1 -1
  5. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +2 -2
  6. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +1 -1
  7. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +1 -1
  8. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +3 -2
  9. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +1 -1
  10. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +3 -3
  11. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +4 -4
  12. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_file_by_version.rb +1 -1
  13. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_download_translations_action.rb +1 -1
  14. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +1 -1
  15. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_firebase_test.rb +1 -1
  16. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb +1 -1
  17. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_trigger_build_action.rb +1 -1
  18. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb +1 -1
  19. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb +1 -1
  20. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb +4 -3
  21. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/extract_release_notes_for_version_action.rb +3 -3
  22. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/find_previous_tag.rb +58 -0
  23. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/get_prs_between_tags.rb +112 -0
  24. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_downloadmetadata_action.rb +5 -5
  25. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb +6 -4
  26. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/promo_screenshots_action.rb +24 -24
  27. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/upload_to_s3.rb +37 -5
  28. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_add_files_to_copy_action.rb +3 -3
  29. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_download_action.rb +3 -3
  30. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_update_action.rb +2 -2
  31. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb +3 -3
  32. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_development_certificates_to_provisioning_profiles.rb +2 -2
  33. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_devices_to_provisioning_profiles.rb +2 -2
  34. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb +1 -1
  35. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_prechecks.rb +4 -4
  36. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_preflight.rb +1 -1
  37. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb +5 -7
  38. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb +3 -22
  39. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb +6 -20
  40. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_codefreeze_prechecks.rb +1 -1
  41. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_completecodefreeze_prechecks.rb +1 -1
  42. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_finalize_prechecks.rb +1 -1
  43. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb +11 -4
  44. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_hotfix_prechecks.rb +1 -1
  45. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_lint_localizations.rb +2 -2
  46. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb +2 -2
  47. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata_source.rb +4 -4
  48. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb +2 -2
  49. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb +39 -41
  50. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +10 -11
  51. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb +1 -1
  52. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb +1 -1
  53. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +39 -1
  54. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb +2 -2
  55. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb +2 -55
  56. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb +3 -3
  57. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb +42 -52
  58. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/metadata_block.rb +20 -0
  59. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_metadata_block.rb +72 -0
  60. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_short_metadata_block.rb +23 -0
  61. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/standard_metadata_block.rb +47 -0
  62. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/unknown_metadata_block.rb +13 -0
  63. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/whats_new_metadata_block.rb +53 -0
  64. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb +13 -13
  65. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb +11 -11
  66. data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +3 -1
  67. metadata +32 -15
  68. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/get_prs_list_action.rb +0 -66
  69. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb +0 -43
  70. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata.rb +0 -40
  71. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/an_metadata_update_helper.rb +0 -152
  72. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb +0 -182
@@ -5,9 +5,9 @@ module Fastlane
5
5
  #
6
6
  module VersionHelper
7
7
  # The key used in internal version Hash objects to hold the versionName value
8
- VERSION_NAME = 'name'
8
+ VERSION_NAME = 'name'.freeze
9
9
  # The key used in internal version Hash objects to hold the versionCode value
10
- VERSION_CODE = 'code'
10
+ VERSION_CODE = 'code'.freeze
11
11
  # The index for the major version number part
12
12
  MAJOR_NUMBER = 0
13
13
  # The index for the minor version number part
@@ -15,9 +15,9 @@ module Fastlane
15
15
  # The index for the hotfix version number part
16
16
  HOTFIX_NUMBER = 2
17
17
  # The prefix used in front of the versionName for alpha versions
18
- ALPHA_PREFIX = 'alpha-'
18
+ ALPHA_PREFIX = 'alpha-'.freeze
19
19
  # The suffix used in the versionName for RC (beta) versions
20
- RC_SUFFIX = '-rc'
20
+ RC_SUFFIX = '-rc'.freeze
21
21
 
22
22
  # Returns the public-facing version string.
23
23
  #
@@ -43,7 +43,7 @@ module Fastlane
43
43
  # @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively
44
44
  #
45
45
  def self.get_release_version
46
- return get_version_from_properties() if File.exist?(version_properties_file)
46
+ return get_version_from_properties if File.exist?(version_properties_file)
47
47
 
48
48
  section = ENV['HAS_ALPHA_VERSION'].nil? ? 'defaultConfig' : 'vanilla {'
49
49
  gradle_path = self.gradle_path
@@ -145,7 +145,7 @@ module Fastlane
145
145
  def self.calc_next_alpha_version(version, alpha_version)
146
146
  # Bump alpha name
147
147
  alpha_number = alpha_version[VERSION_NAME].sub(ALPHA_PREFIX, '')
148
- alpha_name = "#{ALPHA_PREFIX}#{alpha_number.to_i() + 1}"
148
+ alpha_name = "#{ALPHA_PREFIX}#{alpha_number.to_i + 1}"
149
149
 
150
150
  # Bump alpha code
151
151
  alpha_code = version[VERSION_CODE] + 1
@@ -349,7 +349,6 @@ module Fastlane
349
349
  end
350
350
 
351
351
  #----------------------------------------
352
- private
353
352
 
354
353
  # Remove the beta suffix (part after the `-`) from a version string
355
354
  #
@@ -449,8 +448,8 @@ module Fastlane
449
448
  file.each_line do |line|
450
449
  if found_section
451
450
  return line.split[1] if line.include?(keyword) && !line.include?("\"#{keyword}\"") && !line.include?("P#{keyword}")
452
- else
453
- found_section = true if line.include?(section)
451
+ elsif line.include?(section)
452
+ found_section = true
454
453
  end
455
454
  end
456
455
  end
@@ -490,13 +489,13 @@ module Fastlane
490
489
  if line.include?('versionName') && !line.include?('"versionName"') && !line.include?('PversionName')
491
490
  version_name = line.split[1].tr('\"', '')
492
491
  line.sub!(version_name, version[VERSION_NAME].to_s)
493
- version_updated = version_updated + 1
492
+ version_updated += 1
494
493
  end
495
494
 
496
495
  if line.include? 'versionCode'
497
496
  version_code = line.split[1]
498
497
  line.sub!(version_code, version[VERSION_CODE].to_s)
499
- version_updated = version_updated + 1
498
+ version_updated += 1
500
499
  end
501
500
  end
502
501
  temp_file.puts line
@@ -72,7 +72,7 @@ module Fastlane
72
72
  ### NB: Returns nil if the repo is in a detached HEAD state.
73
73
  def self.repo_branch_name
74
74
  result = `cd #{repository_path} && git rev-parse --abbrev-ref HEAD`.strip
75
- (result == 'HEAD') ? nil : result
75
+ result == 'HEAD' ? nil : result
76
76
  end
77
77
 
78
78
  ### Returns the most recent commit hash in the `~/.mobile-secrets` repository.
@@ -47,7 +47,7 @@ module Fastlane
47
47
  def self.has_git_lfs?
48
48
  return false unless is_git_repo?
49
49
 
50
- `git config --get-regex lfs`.length > 0
50
+ !`git config --get-regex lfs`.empty?
51
51
  end
52
52
 
53
53
  # Switch to the given branch and pull its latest commits.
@@ -121,7 +121,7 @@ module Fastlane
121
121
  # @param [TrueClass|FalseClass] prerelease Indicates if this should be created as a pre-release (i.e. for alpha/beta)
122
122
  # @param [TrueClass|FalseClass] is_draft Indicates if this should be created as a draft release
123
123
  #
124
- def create_release(repository:, version:, target: nil, description:, assets:, prerelease:, is_draft:)
124
+ def create_release(repository:, version:, description:, assets:, prerelease:, is_draft:, target: nil)
125
125
  release = client.create_release(
126
126
  repository,
127
127
  version, # tag name
@@ -134,6 +134,44 @@ module Fastlane
134
134
  assets.each do |file_path|
135
135
  client.upload_asset(release[:url], file_path, content_type: 'application/octet-stream')
136
136
  end
137
+ release[:html_url]
138
+ end
139
+
140
+ # Use the GitHub API to generate release notes based on the list of PRs between current tag and previous tag.
141
+ # @note This API uses the `.github/release.yml` config file to classify the PRs by category in the generated list according to PR labels.
142
+ #
143
+ # @param [String] repository The repository to create the GitHub release on. Typically a repo slug (<org>/<repo>).
144
+ # @param [String] tag_name The name of the git tag to generate the changelog for.
145
+ # @param [String] previous_tag The name of the git tag to compare to.
146
+ # @param [String] target_commitish The commit sha1 or branch name to use as the head for the comparison if the `tag_name` tag does not exist yet. Unused if `tag_name` exists.
147
+ # @param [String] config_file_path The path to the GitHub configuration file to use for generating release notes. Will use `.github/release.yml` by default if it exists.
148
+ #
149
+ # @return [String] The string returned by GitHub API listing PRs between `previous_tag` and current `tag_name`
150
+ # @raise [StandardError] Might raise if there was an error during the API call
151
+ #
152
+ def generate_release_notes(repository:, tag_name:, previous_tag:, target_commitish: nil, config_file_path: nil)
153
+ repo_path = Octokit::Repository.path(repository)
154
+ api_url = "#{repo_path}/releases/generate-notes"
155
+ res = client.post(
156
+ api_url,
157
+ tag_name: tag_name,
158
+ target_commitish: target_commitish, # Only used if no git tag named `tag_name` exists yet
159
+ previous_tag_name: previous_tag,
160
+ config_file_path: config_file_path
161
+ )
162
+ res.body
163
+ end
164
+
165
+ # Returns the URL of the GitHub release pointing at a given tag
166
+ # @param [String] repository The repository to create the GitHub release on. Typically a repo slug (<org>/<repo>).
167
+ # @param [String] tag_name The name of the git tag to get the associated release of
168
+ #
169
+ # @return [String] URL of the corresponding GitHub Release, or nil if none was found.
170
+ #
171
+ def get_release_url(repository:, tag_name:)
172
+ client.release_for_tag(repository, tag_name).html_url
173
+ rescue Octokit::NotFound
174
+ nil
137
175
  end
138
176
 
139
177
  # Downloads a file from the given GitHub tag
@@ -4,7 +4,7 @@ module Fastlane
4
4
  module Helper
5
5
  module Ios
6
6
  module ADCAppSizesHelper
7
- DEFAULT_DEVICES = ['Universal', 'iPhone 8', 'iPhone X']
7
+ DEFAULT_DEVICES = ['Universal', 'iPhone 8', 'iPhone X'].freeze
8
8
 
9
9
  # Fetch the App Sizes stats from ADC
10
10
  #
@@ -13,7 +13,7 @@ module Fastlane
13
13
  # Value for key `sizeInBytes` is itself a Hash with one entry per device name (including special name "Universal")
14
14
  # whose value is a Hash with keys `compressed` and `uncompressed`
15
15
  #
16
- def self.get_adc_sizes(adc_user:, adc_team: 'Automattic, Inc.', bundle_id:, only_version: nil, limit: 10)
16
+ def self.get_adc_sizes(adc_user:, bundle_id:, adc_team: 'Automattic, Inc.', only_version: nil, limit: 10)
17
17
  UI.message 'Connecting to ADC...'
18
18
  Spaceship::ConnectAPI.login(adc_user, team_name: adc_team)
19
19
  app = Spaceship::ConnectAPI::App.find(bundle_id)
@@ -8,68 +8,15 @@ module Fastlane
8
8
  #
9
9
  # This typically commits:
10
10
  # - The files in `./config/*` – especially `Version.*.xcconfig` files
11
- # - The `fastlane/Deliverfile` file (which contains the `app_version` line)
12
- # - The `<ProjectRoot>/<ProjectName>/Resources/AppStoreStrings.pot` file, containing a key for that version's release notes
13
11
  #
14
12
  # @env PROJECT_ROOT_FOLDER The path to the git root of the project
15
- # @env PROJECT_NAME The name of the directory containing the project code (especially containing the Resources/ subfolder)
16
13
  #
17
- # @param [Bool] include_deliverfile If true (the default), includes the `fastlane/Deliverfile` in files being commited
18
- # @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)
19
- #
20
- def self.commit_version_bump(include_deliverfile: true, include_metadata: true)
21
- files_list = [File.join(ENV['PROJECT_ROOT_FOLDER'], 'config', '.')]
22
- files_list.append File.join('fastlane', 'Deliverfile') if include_deliverfile
23
- if include_metadata
24
- files_list.append File.join('fastlane', 'download_metadata.swift')
25
- files_list.append File.join(ENV['PROJECT_ROOT_FOLDER'], ENV['PROJECT_NAME'], 'Resources', ENV['APP_STORE_STRINGS_FILE_NAME'])
26
- end
14
+ def self.commit_version_bump
15
+ files_list = [File.join(get_from_env!(key: 'PROJECT_ROOT_FOLDER'), 'config', '.')]
27
16
 
28
17
  Fastlane::Helper::GitHelper.commit(message: 'Bump version number', files: files_list)
29
18
  end
30
19
 
31
- # Calls the `Scripts/localize.py` script in the project root folder and commit the `*.strings` files
32
- #
33
- # That script updates the `.strings` files with translations from GlotPress.
34
- #
35
- # @env PROJECT_ROOT_FOLDER The path to the git root of the project
36
- # @env PROJECT_NAME The name of the directory containing the project code (especially containing the `build.gradle` file)
37
- #
38
- # @deprecated This method is only used by the `ios_localize_project` action, which is itself deprecated
39
- # in favor of the new `ios_generate_strings_file_from_code` action
40
- # @todo [Next Major] Remove this method once we fully remove `ios_localize_project`
41
- #
42
- def self.localize_project
43
- Action.sh("cd #{get_from_env!(key: 'PROJECT_ROOT_FOLDER')} && ./Scripts/localize.py")
44
-
45
- Fastlane::Helper::GitHelper.commit(message: 'Update strings for localization', files: strings_files) || UI.message('No new strings, skipping commit')
46
- end
47
-
48
- # Call the `Scripts/update-translations.rb` then the `fastlane/download_metadata` Scripts from the host project folder
49
- #
50
- # @env PROJECT_ROOT_FOLDER The path to the git root of the project
51
- # @env PROJECT_NAME The name of the directory containing the project code (especially containing the `build.gradle` file)
52
- #
53
- # @todo Migrate the scripts, currently in each host repo and called by this method, to be helpers and actions
54
- # in the release-toolkit instead, and move this code away from `ios_git_helper`.
55
- #
56
- def self.update_metadata
57
- Action.sh("cd #{get_from_env!(key: 'PROJECT_ROOT_FOLDER')} && ./Scripts/update-translations.rb")
58
-
59
- Fastlane::Helper::GitHelper.commit(message: 'Update translations', files: strings_files)
60
-
61
- Action.sh('cd fastlane && ./download_metadata.swift')
62
-
63
- Fastlane::Helper::GitHelper.commit(message: 'Update metadata translations', files: './fastlane/metadata/')
64
- end
65
-
66
- def self.strings_files
67
- project_root = get_from_env!(key: 'PROJECT_ROOT_FOLDER')
68
- project_name = get_from_env!(key: 'PROJECT_NAME')
69
-
70
- Dir.glob(File.join(project_root, project_name, '**', '*.strings'))
71
- end
72
-
73
20
  def self.get_from_env!(key:)
74
21
  ENV.fetch(key) do
75
22
  UI.user_error! "Could not find value for \"#{key}\" in environment."
@@ -5,9 +5,9 @@ module Fastlane
5
5
  module Helper
6
6
  module Ios
7
7
  class L10nLinterHelper
8
- SWIFTGEN_VERSION = '6.4.0'
9
- DEFAULT_BASE_LANG = 'en'
10
- CONFIG_FILE_NAME = 'swiftgen-stringtypes.yml'
8
+ SWIFTGEN_VERSION = '6.4.0'.freeze
9
+ DEFAULT_BASE_LANG = 'en'.freeze
10
+ CONFIG_FILE_NAME = 'swiftgen-stringtypes.yml'.freeze
11
11
 
12
12
  attr_reader :install_path, :version
13
13
 
@@ -1,3 +1,5 @@
1
+ require 'xcodeproj'
2
+
1
3
  module Fastlane
2
4
  module Helper
3
5
  module Ios
@@ -13,12 +15,33 @@ module Fastlane
13
15
  # The index for the build version number part
14
16
  BUILD_NUMBER = 3
15
17
 
18
+ # Returns the public-facing version string.
19
+ #
20
+ # @param [String] xcconfig_file The path for the .xcconfig file containing the public-facing version
21
+ #
22
+ # @return [String] The public-facing version number, extracted from the VERSION_LONG entry of the xcconfig file.
23
+ # - If this version is a hotfix (more than 2 parts and 3rd part is non-zero), returns the "X.Y.Z" formatted string
24
+ # - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number
25
+ #
26
+ def self.get_xcconfig_public_version(xcconfig_file:)
27
+ version = read_long_version_from_config_file(xcconfig_file)
28
+
29
+ UI.user_error!(".xcconfig file doesn't have a version configured") if version.nil?
30
+
31
+ vp = get_version_parts(version)
32
+ return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" unless is_hotfix?(version)
33
+
34
+ "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}"
35
+ end
36
+
16
37
  # Returns the public-facing version string.
17
38
  #
18
39
  # @return [String] The public-facing version number, extracted from the VERSION_LONG entry of the xcconfig file.
19
40
  # - If this version is a hotfix (more than 2 parts and 3rd part is non-zero), returns the "X.Y.Z" formatted string
20
41
  # - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number
21
42
  #
43
+ # @deprecated This method is going to be removed soon due to it's dependency on `ENV['PUBLIC_CONFIG_FILE']` via `get_build_version`.
44
+ #
22
45
  def self.get_public_version
23
46
  version = get_build_version
24
47
  vp = get_version_parts(version)
@@ -139,8 +162,8 @@ module Fastlane
139
162
  def self.create_internal_version(version)
140
163
  vp = get_version_parts(version)
141
164
  d = DateTime.now
142
- todayDate = d.strftime('%Y%m%d')
143
- "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}.#{todayDate}"
165
+ today_date = d.strftime('%Y%m%d')
166
+ "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}.#{today_date}"
144
167
  end
145
168
 
146
169
  # Return the build number value incremented by one.
@@ -169,7 +192,8 @@ module Fastlane
169
192
  # @return [String] The current version according to the public xcconfig file.
170
193
  #
171
194
  def self.get_build_version
172
- versions = get_version_strings()[0]
195
+ xcconfig_file = ENV['PUBLIC_CONFIG_FILE']
196
+ read_long_version_from_config_file(xcconfig_file)
173
197
  end
174
198
 
175
199
  # Returns the current value of the `VERSION_LONG` key from the internal xcconfig file
@@ -177,7 +201,8 @@ module Fastlane
177
201
  # @return [String] The current version according to the internal xcconfig file.
178
202
  #
179
203
  def self.get_internal_version
180
- get_version_strings()[1]
204
+ xcconfig_file = ENV['INTERNAL_CONFIG_FILE']
205
+ read_long_version_from_config_file(xcconfig_file)
181
206
  end
182
207
 
183
208
  # Prints the current and next release version numbers to stdout, then return the next release version
@@ -186,7 +211,7 @@ module Fastlane
186
211
  #
187
212
  def self.bump_version_release
188
213
  # Bump release
189
- current_version = get_public_version()
214
+ current_version = get_public_version
190
215
  UI.message("Current version: #{current_version}")
191
216
  new_version = calc_next_release_version(current_version)
192
217
  UI.message("New version: #{new_version}")
@@ -195,20 +220,6 @@ module Fastlane
195
220
  return verified_version
196
221
  end
197
222
 
198
- # Updates the `app_version` entry in the `Deliverfile`
199
- #
200
- # @param [String] new_version The new value to set the `app_version` entry to.
201
- # @raise [UserError] If the Deliverfile was not found.
202
- #
203
- def self.update_fastlane_deliver(new_version)
204
- fd_file = './fastlane/Deliverfile'
205
- if File.exist?(fd_file)
206
- Action.sh("sed -i '' \"s/app_version.*/app_version \\\"#{new_version}\\\"/\" #{fd_file}")
207
- else
208
- UI.user_error!("Can't find #{fd_file}.")
209
- end
210
- end
211
-
212
223
  # Update the `.xcconfig` files (the public one, and the internal one if it exists) with the new version strings.
213
224
  #
214
225
  # @env PUBLIC_CONFIG_FILE The path to the xcconfig file containing the public version numbers.
@@ -248,7 +259,6 @@ module Fastlane
248
259
  end
249
260
 
250
261
  #----------------------------------------
251
- private
252
262
 
253
263
  # Split a version string into its 4 parts, ensuring its parts count is valid
254
264
  #
@@ -267,54 +277,34 @@ module Fastlane
267
277
 
268
278
  # Extract the VERSION_LONG entry from an `xcconfig` file
269
279
  #
270
- # @param [String] filePath The path to the `.xcconfig` file to read the value from
280
+ # @param [String] file_path The path to the `.xcconfig` file to read the value from
271
281
  # @return [String] The long version found in said xcconfig file, or nil if not found
272
282
  #
273
- def self.read_long_version_from_config_file(filePath)
274
- read_from_config_file('VERSION_LONG', filePath)
283
+ def self.read_long_version_from_config_file(file_path)
284
+ read_from_config_file('VERSION_LONG', file_path)
275
285
  end
276
286
 
277
287
  # Extract the BUILD_NUMBER entry from an `xcconfig` file
278
288
  #
279
- # @param [String] filePath The path to the `.xcconfig` file to read the value from
289
+ # @param [String] file_path The path to the `.xcconfig` file to read the value from
280
290
  # @return [String] The build number found in said xcconfig file, or nil if not found
281
291
  #
282
- def self.read_build_number_from_config_file(filePath)
283
- read_from_config_file('BUILD_NUMBER', filePath)
292
+ def self.read_build_number_from_config_file(file_path)
293
+ read_from_config_file('BUILD_NUMBER', file_path)
284
294
  end
285
295
 
286
296
  # Read the value of a given key from an `.xcconfig` file.
287
297
  #
288
298
  # @param [String] key The xcconfig key to get the value for
289
- # @param [String] filePath The path to the `.xcconfig` file to read the value from
299
+ # @param [String] file_path The path to the `.xcconfig` file to read the value from
290
300
  #
291
301
  # @return [String] The value for the given key, or `nil` if the key was not found.
292
302
  #
293
- def self.read_from_config_file(key, filePath)
294
- File.open(filePath, 'r') do |f|
295
- f.each_line do |line|
296
- line = line.strip()
297
- return line.split('=')[1] if line.start_with?("#{key}=")
298
- end
299
- end
300
-
301
- return nil
302
- end
303
-
304
- # Read the version numbers from the xcconfig file
305
- #
306
- # @env PUBLIC_CONFIG_FILE The path to the xcconfig file containing the public version numbers.
307
- # @env INTERNAL_CONFIG_FILE The path to the xcconfig file containing the internal version numbers. Can be nil.
308
- #
309
- # @return [String] Array of long version strings found.
310
- # The first element is always present and contains the version extracted from the public config file
311
- # The second element is the version extracted from the internal config file, only present if one was provided.
312
- def self.get_version_strings
313
- version_strings = []
314
- version_strings << read_long_version_from_config_file(ENV['PUBLIC_CONFIG_FILE'])
315
- version_strings << read_long_version_from_config_file(ENV['INTERNAL_CONFIG_FILE']) unless ENV['INTERNAL_CONFIG_FILE'].nil?
303
+ def self.read_from_config_file(key, file_path)
304
+ UI.user_error!(".xcconfig file #{file_path} not found") unless File.exist?(file_path)
316
305
 
317
- return version_strings
306
+ config = Xcodeproj::Config.new(file_path)
307
+ config.attributes[key]
318
308
  end
319
309
 
320
310
  # Ensure that the version provided is only composed of number parts and return the validated string
@@ -339,7 +329,7 @@ module Fastlane
339
329
  #
340
330
  # @return [Bool] true if the string is representing an integer value, false if not
341
331
  #
342
- def self.is_int? string
332
+ def self.is_int?(string)
343
333
  true if Integer(string) rescue false
344
334
  end
345
335
  end
@@ -0,0 +1,20 @@
1
+ module Fastlane
2
+ module Helper
3
+ # Basic line handler
4
+ class MetadataBlock
5
+ attr_reader :block_key
6
+
7
+ def initialize(block_key)
8
+ @block_key = block_key
9
+ end
10
+
11
+ def handle_line(file, line)
12
+ file.puts(line) # Standard line handling: just copy
13
+ end
14
+
15
+ def is_handler_for(key)
16
+ true
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,72 @@
1
+ require_relative 'metadata_block'
2
+ require_relative 'standard_metadata_block'
3
+
4
+ module Fastlane
5
+ module Helper
6
+ class ReleaseNoteMetadataBlock < StandardMetadataBlock
7
+ attr_reader :new_key, :keep_key, :rel_note_key, :release_version
8
+
9
+ def initialize(block_key, content_file_path, release_version)
10
+ super(block_key, content_file_path)
11
+ @rel_note_key = 'release_note'
12
+ @release_version = release_version
13
+ generate_keys(release_version)
14
+ end
15
+
16
+ def generate_keys(release_version)
17
+ values = release_version.split('.')
18
+ version_major = Integer(values[0])
19
+ version_minor = Integer(values[1])
20
+ @new_key = "#{@rel_note_key}_#{version_major.to_s.rjust(2, '0')}#{version_minor}"
21
+
22
+ version_major -= 1 if version_minor.zero?
23
+ version_minor = version_minor.zero? ? 9 : version_minor - 1
24
+
25
+ @keep_key = "#{@rel_note_key}_#{version_major.to_s.rjust(2, '0')}#{version_minor}"
26
+ end
27
+
28
+ def is_handler_for(key)
29
+ values = key.split('_')
30
+ key.start_with?(@rel_note_key) && values.length == 3 && is_int?(values[2].sub(/^0*/, ''))
31
+ end
32
+
33
+ def handle_line(file, line)
34
+ # put content on block start or if copying the latest one
35
+ # and skip all the other content
36
+ if line.start_with?('msgctxt')
37
+ key = extract_key(line)
38
+ @is_copying = (key == @keep_key)
39
+ generate_block(file) if @is_copying
40
+ end
41
+
42
+ file.puts(line) if @is_copying
43
+ end
44
+
45
+ def generate_block(file)
46
+ # init
47
+ file.puts("msgctxt \"#{@new_key}\"")
48
+ file.puts('msgid ""')
49
+ file.puts("\"#{@release_version}:\\n\"")
50
+
51
+ # insert content
52
+ File.open(@content_file_path, 'r').each do |line|
53
+ file.puts("\"#{line.strip}\\n\"")
54
+ end
55
+
56
+ # close
57
+ file.puts('msgstr ""')
58
+ file.puts('')
59
+ end
60
+
61
+ def extract_key(line)
62
+ line.split[1].tr('\"', '')
63
+ end
64
+
65
+ def is_int?(value)
66
+ true if Integer(value)
67
+ rescue StandardError
68
+ false
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'release_note_metadata_block'
2
+
3
+ module Fastlane
4
+ module Helper
5
+ class ReleaseNoteShortMetadataBlock < ReleaseNoteMetadataBlock
6
+ def initialize(block_key, content_file_path, release_version)
7
+ super(block_key, content_file_path, release_version)
8
+ @rel_note_key = 'release_note_short'
9
+ @release_version = release_version
10
+ generate_keys(release_version)
11
+ end
12
+
13
+ def is_handler_for(key)
14
+ values = key.split('_')
15
+ key.start_with?(@rel_note_key) && values.length == 4 && is_int?(values[3].sub(/^0*/, ''))
16
+ end
17
+
18
+ def generate_block(file)
19
+ super(file) unless File.empty?(@content_file_path)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,47 @@
1
+ require_relative 'metadata_block'
2
+
3
+ module Fastlane
4
+ module Helper
5
+ class StandardMetadataBlock < MetadataBlock
6
+ attr_reader :content_file_path
7
+
8
+ def initialize(block_key, content_file_path)
9
+ super(block_key)
10
+ @content_file_path = content_file_path
11
+ end
12
+
13
+ def is_handler_for(key)
14
+ key == @block_key.to_s
15
+ end
16
+
17
+ def handle_line(file, line)
18
+ # put the new content on block start
19
+ # and skip all the other content
20
+ generate_block(file) if line.start_with?('msgctxt')
21
+ end
22
+
23
+ def generate_block(file)
24
+ # init
25
+ file.puts("msgctxt \"#{@block_key}\"")
26
+ line_count = File.foreach(@content_file_path).inject(0) { |c, _line| c + 1 }
27
+
28
+ if line_count <= 1
29
+ # Single line output
30
+ file.puts("msgid \"#{File.read(@content_file_path).rstrip}\"")
31
+ else
32
+ # Multiple line output
33
+ file.puts('msgid ""')
34
+
35
+ # insert content
36
+ File.open(@content_file_path, 'r').each do |line|
37
+ file.puts("\"#{line.strip}\\n\"")
38
+ end
39
+ end
40
+
41
+ # close
42
+ file.puts('msgstr ""')
43
+ file.puts('')
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'metadata_block'
2
+
3
+ module Fastlane
4
+ module Helper
5
+ class UnknownMetadataBlock < MetadataBlock
6
+ attr_reader :content_file_path
7
+
8
+ def initialize
9
+ super(nil)
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,53 @@
1
+ require_relative 'standard_metadata_block'
2
+
3
+ module Fastlane
4
+ module Helper
5
+ class WhatsNewMetadataBlock < StandardMetadataBlock
6
+ attr_reader :new_key, :old_key, :rel_note_key, :release_version
7
+
8
+ def initialize(block_key, content_file_path, release_version)
9
+ super(block_key, content_file_path)
10
+ @rel_note_key = 'whats_new'
11
+ @release_version = release_version
12
+ generate_keys(release_version)
13
+ end
14
+
15
+ def generate_keys(release_version)
16
+ values = release_version.split('.')
17
+ version_major = Integer(values[0])
18
+ version_minor = Integer(values[1])
19
+ @new_key = "v#{release_version}-whats-new"
20
+
21
+ version_major -= 1 if version_minor.zero?
22
+ version_minor = version_minor.zero? ? 9 : version_minor - 1
23
+
24
+ @old_key = "v#{version_major}.#{version_minor}-whats-new"
25
+ end
26
+
27
+ def is_handler_for(key)
28
+ key.start_with?('v') && key.end_with?('-whats-new')
29
+ end
30
+
31
+ def handle_line(file, line)
32
+ # put content on block start or if copying the latest one
33
+ # and skip all the other content
34
+ generate_block(file) if line.start_with?('msgctxt')
35
+ end
36
+
37
+ def generate_block(file)
38
+ # init
39
+ file.puts("msgctxt \"#{@new_key}\"")
40
+ file.puts('msgid ""')
41
+
42
+ # insert content
43
+ File.open(@content_file_path, 'r').each do |line|
44
+ file.puts("\"#{line.strip}\\n\"")
45
+ end
46
+
47
+ # close
48
+ file.puts('msgstr ""')
49
+ file.puts('')
50
+ end
51
+ end
52
+ end
53
+ end