fastlane-plugin-wpmreleasetoolkit 8.0.1 → 9.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb +7 -7
  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 +13 -6
  25. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb +3 -3
  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/an_metadata_update_helper.rb +6 -6
  50. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_localize_helper.rb +39 -41
  51. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +10 -11
  52. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb +1 -1
  53. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb +1 -1
  54. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +39 -1
  55. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_adc_app_sizes_helper.rb +2 -2
  56. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb +2 -55
  57. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_l10n_linter_helper.rb +3 -3
  58. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb +42 -52
  59. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_download_helper.rb +26 -16
  60. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata_update_helper.rb +2 -2
  61. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/promo_screenshots_helper.rb +11 -11
  62. data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +3 -1
  63. metadata +26 -13
  64. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/get_prs_list_action.rb +0 -66
  65. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_localize_project.rb +0 -43
  66. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_update_metadata.rb +0 -40
@@ -1,7 +1,7 @@
1
1
  module Fastlane
2
2
  module Helper
3
3
  # Basic line handler
4
- class MetadataBlock
4
+ class AnMetadataBlock
5
5
  attr_reader :block_key
6
6
 
7
7
  def initialize(block_key)
@@ -17,7 +17,7 @@ module Fastlane
17
17
  end
18
18
  end
19
19
 
20
- class UnknownMetadataBlock < MetadataBlock
20
+ class AnUnknownMetadataBlock < AnMetadataBlock
21
21
  attr_reader :content_file_path
22
22
 
23
23
  def initialize
@@ -25,7 +25,7 @@ module Fastlane
25
25
  end
26
26
  end
27
27
 
28
- class StandardMetadataBlock < MetadataBlock
28
+ class AnStandardMetadataBlock < AnMetadataBlock
29
29
  attr_reader :content_file_path
30
30
 
31
31
  def initialize(block_key, content_file_path)
@@ -67,7 +67,7 @@ module Fastlane
67
67
  end
68
68
  end
69
69
 
70
- class ReleaseNoteMetadataBlock < StandardMetadataBlock
70
+ class AnReleaseNoteMetadataBlock < AnStandardMetadataBlock
71
71
  attr_reader :new_key, :keep_key, :rel_note_key, :release_version
72
72
 
73
73
  def initialize(block_key, content_file_path, release_version)
@@ -83,7 +83,7 @@ module Fastlane
83
83
  version_minor = Integer(values[1])
84
84
  @new_key = "#{@rel_note_key}_#{version_major.to_s.rjust(2, '0')}#{version_minor}"
85
85
 
86
- version_major = version_major - 1 if version_minor == 0
86
+ version_major -= 1 if version_minor == 0
87
87
  version_minor = version_minor == 0 ? 9 : version_minor - 1
88
88
 
89
89
  @keep_key = "#{@rel_note_key}_#{version_major.to_s.rjust(2, '0')}#{version_minor}"
@@ -131,7 +131,7 @@ module Fastlane
131
131
  end
132
132
  end
133
133
 
134
- class ReleaseNoteShortMetadataBlock < ReleaseNoteMetadataBlock
134
+ class AnReleaseNoteShortMetadataBlock < AnReleaseNoteMetadataBlock
135
135
  def initialize(block_key, content_file_path, release_version)
136
136
  super(block_key, content_file_path, release_version)
137
137
  @rel_note_key = 'release_note_short'
@@ -54,30 +54,29 @@ module Fastlane
54
54
  # Search for the string in the main file
55
55
  result = :added
56
56
  main_strings_xml.xpath('//string').each do |main_string_node|
57
- if main_string_node.attr('name') == string_name
58
- # Skip if the string has the content_override tag
59
- return :skipped if skip_string_by_tag?(main_string_node)
60
-
61
- # If nodes are equivalent, skip
62
- return :found if lib_string_node =~ main_string_node
63
-
64
- # The string needs an update
65
- if main_string_node.attr('tools:ignore').nil?
66
- # No `tools:ignore` attribute; completely replace existing main string node with lib's one
67
- add_xml_attributes!(lib_string_node, library)
68
- main_string_node.replace lib_string_node
69
- else
70
- # Has the `tools:ignore` flag; update the content without touching the other existing attributes
71
- add_xml_attributes!(main_string_node, library)
72
- main_string_node.content = string_content
73
- end
74
- return :updated
57
+ next unless main_string_node.attr('name') == string_name
58
+ # Skip if the string has the content_override tag
59
+ return :skipped if skip_string_by_tag?(main_string_node)
60
+
61
+ # If nodes are equivalent, skip
62
+ return :found if lib_string_node =~ main_string_node
63
+
64
+ # The string needs an update
65
+ if main_string_node.attr('tools:ignore').nil?
66
+ # No `tools:ignore` attribute; completely replace existing main string node with lib's one
67
+ add_xml_attributes!(lib_string_node, library)
68
+ main_string_node.replace lib_string_node
69
+ else
70
+ # Has the `tools:ignore` flag; update the content without touching the other existing attributes
71
+ add_xml_attributes!(main_string_node, library)
72
+ main_string_node.content = string_content
75
73
  end
74
+ return :updated
76
75
  end
77
76
 
78
77
  # String not found, or removed because needing update and not in the exclusion list: add to the main file
79
78
  add_xml_attributes!(lib_string_node, library)
80
- main_strings_xml.xpath('//string').last().add_next_sibling("\n#{' ' * 4}#{lib_string_node.to_xml().strip}")
79
+ main_strings_xml.xpath('//string').last.add_next_sibling("\n#{' ' * 4}#{lib_string_node.to_xml.strip}")
81
80
  return result
82
81
  end
83
82
 
@@ -91,14 +90,13 @@ module Fastlane
91
90
 
92
91
  # Search for the string in the main file
93
92
  main_strings_xml.xpath('//string').each do |main_string_node|
94
- if main_string_node.attr('name') == string_name
95
- # Skip if the string has the content_override tag
96
- return if skip_string_by_tag?(main_string_node)
93
+ next unless main_string_node.attr('name') == string_name
94
+ # Skip if the string has the content_override tag
95
+ return if skip_string_by_tag?(main_string_node)
97
96
 
98
- # Check if up-to-date
99
- UI.user_error!("String #{string_name} [#{string_content}] has been updated in the main file but not in the library #{library[:library]}.") if main_string_node.content != string_content
100
- return
101
- end
97
+ # Check if up-to-date
98
+ UI.user_error!("String #{string_name} [#{string_content}] has been updated in the main file but not in the library #{library[:library]}.") if main_string_node.content != string_content
99
+ return
102
100
  end
103
101
 
104
102
  # String not found and not in the exclusion list
@@ -133,14 +131,14 @@ module Fastlane
133
131
  case res
134
132
  when :updated
135
133
  UI.verbose "#{string_node.attr('name')} updated."
136
- updated_count = updated_count + 1
134
+ updated_count += 1
137
135
  when :found
138
- untouched_count = untouched_count + 1
136
+ untouched_count += 1
139
137
  when :added
140
138
  UI.verbose "#{string_node.attr('name')} added."
141
- added_count = added_count + 1
139
+ added_count += 1
142
140
  when :skipped
143
- skipped_count = skipped_count + 1
141
+ skipped_count += 1
144
142
  else
145
143
  UI.user_error!("Internal Error! #{res}")
146
144
  end
@@ -180,22 +178,22 @@ module Fastlane
180
178
 
181
179
  def self.verify_local_diff(main, library, main_strings, lib_strings)
182
180
  `git diff #{main}`.each_line do |line|
183
- if line.start_with?('+ ') || line.start_with?('- ')
184
- diffs = line.gsub(/\s+/m, ' ').strip.split
185
- diffs.each do |diff|
186
- verify_diff(diff, main_strings, lib_strings, library)
187
- end
181
+ next unless line.start_with?('+ ') || line.start_with?('- ')
182
+
183
+ diffs = line.gsub(/\s+/m, ' ').strip.split
184
+ diffs.each do |diff|
185
+ verify_diff(diff, main_strings, lib_strings, library)
188
186
  end
189
187
  end
190
188
  end
191
189
 
192
190
  def self.verify_pr_diff(main, library, main_strings, lib_strings, source_diff)
193
191
  source_diff.each_line do |line|
194
- if line.start_with?('+ ') || line.start_with?('- ')
195
- diffs = line.gsub(/\s+/m, ' ').strip.split
196
- diffs.each do |diff|
197
- verify_diff(diff, main_strings, lib_strings, library)
198
- end
192
+ next unless line.start_with?('+ ') || line.start_with?('- ')
193
+
194
+ diffs = line.gsub(/\s+/m, ' ').strip.split
195
+ diffs.each do |diff|
196
+ verify_diff(diff, main_strings, lib_strings, library)
199
197
  end
200
198
  end
201
199
  end
@@ -234,7 +232,7 @@ module Fastlane
234
232
  # An array of locales to download. Each item in the array must be a Hash
235
233
  # with keys `:glotpress` and `:android` containing the respective locale codes.
236
234
  #
237
- def self.download_from_glotpress(res_dir:, glotpress_project_url:, glotpress_filters: { status: 'current' }, locales_map:)
235
+ def self.download_from_glotpress(res_dir:, glotpress_project_url:, locales_map:, glotpress_filters: { status: 'current' })
238
236
  glotpress_filters = [glotpress_filters] unless glotpress_filters.is_a?(Array)
239
237
 
240
238
  attributes_to_copy = %w[formatted] # Attributes that we want to replicate into translated `string.xml` files
@@ -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