fastlane-plugin-wpmreleasetoolkit 13.0.0 → 13.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 18c81344c45a90d79220d70143cda3ff32ba7a3d1c38bba9cc314d65b4da298a
4
- data.tar.gz: 465273421965607cba8aec468763025dc2f2f0bf611204bf0e432b84f8f29c7d
3
+ metadata.gz: 202b4a58edac9a14316472344b1d6846af0e39c0c3596a19e02dfb12a57b6e21
4
+ data.tar.gz: be0de1e413c994c8af7060ab988343610843c940244a91c41e12fed0fc9c2e6f
5
5
  SHA512:
6
- metadata.gz: 67a1362ed01a86a83c40e5dc0c1f83e488601c132d168f3779b3f2d681ce06278a2d4d2cebd2b92d24c5fc744ea1d0e9d93a547d484d13a9950449ad429dcbea
7
- data.tar.gz: c653d40521801bb9722c8ae5a6418359a269c5107271f732b9657e883d0f669eacfe6e5d072106c0d5eb9015b091dc20a4ebcd58b2ba4aba7afa5f10611397e0
6
+ metadata.gz: 9cca3a4720bde57c7dabd408203702b929fbcc008409546dd7e7ad2f49de786016bb80da8d62b7091ece5ef0568b7146761634492c07123c50c046c98dd8354d
7
+ data.tar.gz: c7853ac08d918d06f73c61cbf9302242ff970aa0859b9a788c9e32ae3efd6311f812976e3cb8b5b078da6a05debd7485e98a733c39223f693de34bf87adae326
@@ -9,6 +9,7 @@ module Fastlane
9
9
  DEFAULT_BRANCH = 'trunk'
10
10
 
11
11
  def self.run(params)
12
+ api_url = params[:api_url]
12
13
  token = params[:github_token]
13
14
  repository = params[:repository]
14
15
  source_branch = params[:source_branch]
@@ -41,6 +42,7 @@ module Fastlane
41
42
  Fastlane::Helper::GitHelper.checkout_and_pull(source_branch)
42
43
 
43
44
  create_backmerge_pr(
45
+ api_url: api_url,
44
46
  token: token,
45
47
  repository: repository,
46
48
  title: "Merge #{source_branch} into #{target_branch}",
@@ -76,6 +78,7 @@ module Fastlane
76
78
 
77
79
  # Creates a backmerge pull request using the `create_pull_request` Fastlane Action.
78
80
  #
81
+ # @param api_url [String] the GitHub API URL to use for creating the pull request
79
82
  # @param token [String] the GitHub token for authentication.
80
83
  # @param repository [String] the repository where the pull request will be created.
81
84
  # @param title [String] the title of the pull request.
@@ -90,7 +93,7 @@ module Fastlane
90
93
  #
91
94
  # @return [String] The URL of the created Pull Request, or `nil` if no PR was created.
92
95
  #
93
- def self.create_backmerge_pr(token:, repository:, title:, head_branch:, base_branch:, labels:, milestone:, reviewers:, team_reviewers:, intermediate_branch_created_callback:)
96
+ def self.create_backmerge_pr(api_url:, token:, repository:, title:, head_branch:, base_branch:, labels:, milestone:, reviewers:, team_reviewers:, intermediate_branch_created_callback:) # rubocop:disable Metrics/ParameterLists
94
97
  # Do an early pre-check to see if the PR would be valid, but only if no callback (as a callback might add new commits on intermediate branch)
95
98
  if intermediate_branch_created_callback.nil? && !can_merge?(head_branch, into: base_branch)
96
99
  UI.error("Nothing to merge from #{head_branch} into #{base_branch}. Skipping PR creation.")
@@ -108,7 +111,9 @@ module Fastlane
108
111
 
109
112
  # Call the callback if one was provided to allow the use to add commits on the intermediate branch (e.g. solve conflicts)
110
113
  unless intermediate_branch_created_callback.nil?
111
- intermediate_branch_created_callback.call(base_branch, intermediate_branch)
114
+ Dir.chdir(FastlaneCore::FastlaneFolder.path) do
115
+ intermediate_branch_created_callback.call(base_branch, intermediate_branch)
116
+ end
112
117
  # Make sure the callback block didn't switch branches
113
118
  other_action.ensure_git_branch(branch: "^#{intermediate_branch}$")
114
119
 
@@ -120,7 +125,7 @@ module Fastlane
120
125
  end
121
126
  end
122
127
 
123
- other_action.push_to_git_remote(tags: false)
128
+ other_action.push_to_git_remote(tags: false, remote_branch: intermediate_branch, set_upstream: true)
124
129
 
125
130
  pr_body = <<~BODY
126
131
  Merging `#{head_branch}` into `#{base_branch}`.
@@ -136,6 +141,7 @@ module Fastlane
136
141
  BODY
137
142
 
138
143
  other_action.create_pull_request(
144
+ api_url: api_url,
139
145
  api_token: token,
140
146
  repo: repository,
141
147
  title: title,
@@ -191,50 +197,63 @@ module Fastlane
191
197
  end
192
198
 
193
199
  def self.available_options
200
+ # Parameters we want to forward from Fastlane's create_pull_request action
201
+ forwarded_param_keys = %i[
202
+ api_url
203
+ labels
204
+ assignees
205
+ reviewers
206
+ team_reviewers
207
+ ].freeze
208
+
209
+ forwarded_params = Fastlane::Actions::CreatePullRequestAction.available_options.select do |opt|
210
+ forwarded_param_keys.include?(opt.key)
211
+ end
212
+
194
213
  [
195
- FastlaneCore::ConfigItem.new(key: :repository,
196
- env_name: 'GHHELPER_REPOSITORY',
197
- description: 'The remote path of the GH repository on which we work',
198
- optional: false,
199
- type: String),
200
- FastlaneCore::ConfigItem.new(key: :source_branch,
201
- description: 'The source branch to create a backmerge PR from, in the format `release/x.y.z`',
202
- optional: false,
203
- type: String),
204
- FastlaneCore::ConfigItem.new(key: :default_branch,
205
- description: 'The default branch to target if no newer release branches exist',
206
- optional: true,
207
- default_value: DEFAULT_BRANCH,
208
- type: String),
209
- FastlaneCore::ConfigItem.new(key: :target_branches,
210
- description: 'Array of target branches for the backmerge. If empty, the action will determine target branches by finding all `release/x.y.z` branches with a `x.y.z` version greater than the version in source branch\'s name. If none are found, it will target `default_branch`', # rubocop:disable Layout/LineLength
211
- optional: true,
212
- default_value: [],
213
- type: Array),
214
- FastlaneCore::ConfigItem.new(key: :labels,
215
- description: 'The labels that should be assigned to the backmerge PRs',
216
- optional: true,
217
- default_value: [],
218
- type: Array),
219
- FastlaneCore::ConfigItem.new(key: :milestone_title,
220
- description: 'The title of the milestone to assign to the created PRs',
221
- optional: true,
222
- type: String),
223
- FastlaneCore::ConfigItem.new(key: :reviewers,
224
- description: 'An array of GitHub users that will be assigned to the pull request',
225
- optional: true,
226
- type: Array),
227
- FastlaneCore::ConfigItem.new(key: :team_reviewers,
228
- description: 'An array of GitHub team slugs that will be assigned to the pull request',
229
- optional: true,
230
- type: Array),
231
- FastlaneCore::ConfigItem.new(key: :intermediate_branch_created_callback,
232
- description: 'Callback to allow for the caller to perform operations on the intermediate branch (e.g. pushing new commits to pre-solve conflicts) before creating the PR. ' \
233
- + 'The callback receives two parameters: the base (target) branch for the PR and the intermediate branch name that has been created.' \
234
- + 'Note that if you use the callback to add new commits to the intermediate branch, you are responsible for git-pushing them too',
235
- optional: true,
236
- type: Proc),
237
- Fastlane::Helper::GithubHelper.github_token_config_item,
214
+ *forwarded_params,
215
+ Fastlane::Helper::GithubHelper.github_token_config_item, # we forward `github_token` to `api_token` in the `create_pull_request` action
216
+ FastlaneCore::ConfigItem.new(
217
+ key: :repository,
218
+ env_name: 'GHHELPER_REPOSITORY',
219
+ description: 'The remote path of the GH repository on which we work',
220
+ optional: false,
221
+ type: String
222
+ ),
223
+ FastlaneCore::ConfigItem.new(
224
+ key: :source_branch,
225
+ description: 'The source branch to create a backmerge PR from, in the format `release/x.y.z`',
226
+ optional: false,
227
+ type: String
228
+ ),
229
+ FastlaneCore::ConfigItem.new(
230
+ key: :default_branch,
231
+ description: 'The default branch to target if no newer release branches exist',
232
+ optional: true,
233
+ default_value: DEFAULT_BRANCH,
234
+ type: String
235
+ ),
236
+ FastlaneCore::ConfigItem.new(
237
+ key: :target_branches,
238
+ description: 'Array of target branches for the backmerge. If empty, the action will determine target branches by finding all `release/x.y.z` branches with a `x.y.z` version greater than the version in source branch\'s name. If none are found, it will target `default_branch`',
239
+ optional: true,
240
+ default_value: [],
241
+ type: Array
242
+ ),
243
+ FastlaneCore::ConfigItem.new(
244
+ key: :milestone_title,
245
+ description: 'The title of the milestone to assign to the created PRs',
246
+ optional: true,
247
+ type: String
248
+ ),
249
+ FastlaneCore::ConfigItem.new(
250
+ key: :intermediate_branch_created_callback,
251
+ description: 'Callback to allow for the caller to perform operations on the intermediate branch (e.g. pushing new commits to pre-solve conflicts) before creating the PR. ' \
252
+ + 'The callback receives two parameters: the base (target) branch for the PR and the intermediate branch name that has been created.' \
253
+ + 'Note that if you use the callback to add new commits to the intermediate branch, you are responsible for git-pushing them too',
254
+ optional: true,
255
+ type: Proc
256
+ ),
238
257
  ]
239
258
  end
240
259
 
@@ -10,11 +10,11 @@ module Fastlane
10
10
  release_notes_file_path = params[:release_notes_file_path]
11
11
  extracted_notes_file_path = params[:extracted_notes_file_path]
12
12
 
13
- extracted_notes = ''
13
+ extracted_lines = []
14
14
  extract_notes(release_notes_file_path, version) do |line|
15
- extracted_notes += line
15
+ extracted_lines << line
16
16
  end
17
- extracted_notes.chomp!('') # Remove any extra empty line(s) at the end
17
+ extracted_notes = extracted_lines.join.chomp('') # Combine lines and remove any extra empty line(s) at the end
18
18
 
19
19
  unless extracted_notes_file_path.nil? || extracted_notes_file_path.empty?
20
20
  File.write(extracted_notes_file_path, extracted_notes)
@@ -102,12 +102,15 @@ module Fastlane
102
102
  # @return [Hash<String, String>] A hash of all the metadata, consolidated from both the explicit and the implicit ones
103
103
  #
104
104
  def self.generate_metadata_hash(params:, release_info:)
105
+ # Add explicit metadata provided by the caller
105
106
  metadata = params[:metadata]&.transform_keys(&:to_s) || {}
106
107
 
107
108
  # Add Firebase-specific metadata if available
108
- metadata['Build Number'] ||= "<code>#{release_info&.build_version}</code>"
109
- metadata['Version'] ||= "<code>#{release_info&.display_version}</code>"
110
- metadata[release_info&.os == 'ios' ? 'Bundle ID' : 'Application ID'] ||= "<code>#{release_info&.bundle_id}</code>"
109
+ unless release_info.nil?
110
+ metadata['Build Number'] ||= "<code>#{release_info.build_version}</code>"
111
+ metadata['Version'] ||= "<code>#{release_info.display_version}</code>"
112
+ metadata[release_info.os == 'ios' ? 'Bundle ID' : 'Application ID'] ||= "<code>#{release_info.bundle_id}</code>"
113
+ end
111
114
 
112
115
  # Add git metadata
113
116
  metadata['Commit'] ||= ENV.fetch('BUILDKITE_COMMIT', nil) || other_action.last_git_commit[:abbreviated_commit_hash]
@@ -342,7 +342,10 @@ module Fastlane
342
342
  #
343
343
  def self.post_process_xml!(translated_xml, locale_code:, original_xml:)
344
344
  copy_orig_attributes = lambda do |node, xpath|
345
- orig_attributes = original_xml.xpath(xpath)&.first&.attribute_nodes&.to_h do |attr|
345
+ found_node = original_xml.xpath(xpath)&.first
346
+ return unless found_node
347
+
348
+ orig_attributes = found_node.attribute_nodes&.to_h do |attr|
346
349
  [[attr.namespace&.prefix, attr.name].compact.join(':'), attr.value]
347
350
  end
348
351
  orig_attributes&.each { |k, v| node[k] = v unless k == 'name' }
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fastlane'
4
+
5
+ # This monkey-patch adds Buildkite-aware logs to fastlane so it generates a collapsible log group in Buildkite for each action execution.
6
+ #
7
+ # @env `FASTLANE_DISABLE_ACTIONS_BUILDKITE_LOG_GROUPS`
8
+ # Set this variable to '1' to disable the auto-application of the monkey patch.
9
+
10
+ unless !ENV.key?('BUILDKITE') || FastlaneCore::Env.truthy?('FASTLANE_DISABLE_ACTIONS_BUILDKITE_LOG_GROUPS')
11
+ FastlaneCore::UI.verbose('Monkey-patching fastlane to add Buildkite-aware log groups for each action execution')
12
+
13
+ module Fastlane
14
+ module Actions
15
+ module SharedValues
16
+ # This differs from the existing `SharedValues::LANE_NAME`, which always contains the name of the **top-level** lane
17
+ CURRENTLY_RUNNING_LANE_NAME = :CURRENTLY_RUNNING_LANE_NAME
18
+ end
19
+
20
+ module BuildkiteLogActionsAsCollapsibleGroups
21
+ def execute_action(action_name, &)
22
+ unless %w[is_ci? is_ci].include?(action_name)
23
+ current_lane = lane_context[SharedValues::CURRENTLY_RUNNING_LANE_NAME]
24
+ lane_name_prefix = (current_lane || '').empty? ? '' : "[lane :#{current_lane}]"
25
+ puts "~~~ :fastlane: #{lane_name_prefix} #{action_name}"
26
+ end
27
+ super
28
+ end
29
+ end
30
+
31
+ class << self
32
+ prepend BuildkiteLogActionsAsCollapsibleGroups
33
+ end
34
+ end
35
+
36
+ class Runner
37
+ prepend(Module.new do
38
+ def current_lane=(lane_name)
39
+ super
40
+ Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::CURRENTLY_RUNNING_LANE_NAME] = lane_name
41
+ end
42
+ end)
43
+ end
44
+ end
45
+ end
@@ -54,7 +54,7 @@ module Fastlane
54
54
  csv = "Version\t#{devices.join("\t")}\n"
55
55
  app_sizes.each do |details|
56
56
  build_number = details['cfBundleVersion']
57
- sizes = details['sizesInBytes'].select { |name, _| devices.include?(name) }
57
+ sizes = details['sizesInBytes'].slice(*devices)
58
58
  csv += "#{build_number}\t" + devices.map { |d| sz(sizes[d]['compressed']) }.join("\t") + "\n"
59
59
  end
60
60
  csv
@@ -64,7 +64,7 @@ module Fastlane
64
64
  devices = DEFAULT_DEVICES if devices.nil? || devices.empty?
65
65
  app_sizes.map do |details|
66
66
  build_number = details['cfBundleVersion']
67
- sizes = details['sizesInBytes'].select { |name, _| devices.include?(name) }
67
+ sizes = details['sizesInBytes'].slice(*devices)
68
68
  col_size = devices.map(&:length).max
69
69
  table = "| #{build_number.ljust(col_size)} | Download | Install |\n"
70
70
  table += "|:#{'-' * col_size}-|---------:|---------:|\n"
@@ -65,10 +65,10 @@ module Fastlane
65
65
  # Inspects the given `.strings` file for duplicated keys, returning them if any.
66
66
  #
67
67
  # @param [String] file The path to the file to inspect.
68
- # @return [Hash<String, Array<Int>] Hash with the dublipcated keys.
68
+ # @return [Hash<String, Array<Int>] Hash with the duplicated keys.
69
69
  # Each element has the duplicated key (from the `.strings`) as key and an array of line numbers where the key occurs as value.
70
70
  def self.find_duplicated_keys(file:)
71
- keys_with_lines = Hash.new([])
71
+ keys_with_lines = Hash.new { |h, k| h[k] = [] }
72
72
 
73
73
  state = State.new(context: :root, buffer: StringIO.new, in_escaped_ctx: false, found_key: nil)
74
74
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fastlane
4
4
  module Wpmreleasetoolkit
5
- VERSION = '13.0.0'
5
+ VERSION = '13.1.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-wpmreleasetoolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.0.0
4
+ version: 13.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Automattic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-11 00:00:00.000000000 Z
11
+ date: 2025-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -457,6 +457,7 @@ files:
457
457
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_tools_path_helper.rb
458
458
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb
459
459
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/app_size_metrics_helper.rb
460
+ - lib/fastlane/plugin/wpmreleasetoolkit/helper/buildkite_aware_log_groups.rb
460
461
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/ci_helper.rb
461
462
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb
462
463
  - lib/fastlane/plugin/wpmreleasetoolkit/helper/encryption_helper.rb