fastlane-plugin-wpmreleasetoolkit 12.0.0 → 12.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f4bad14f2aca7e44fede245ed91674426c688395c9d6a5085a4d25a5e30e361
4
- data.tar.gz: 66e0440a5340b12dff4a5e35c37759c48d04c8f157e83e4c57ca94cde2c4135e
3
+ metadata.gz: 5efb1f6f88d1bb1617313112768ef93497cabe3897bb4834c5026a4e9a68ced0
4
+ data.tar.gz: 8eaef85d47b2ec7be3e2da0693856923c02e6f67b65707e4143d7241147a7435
5
5
  SHA512:
6
- metadata.gz: 1ed67cfa98a54dfe351d5e90ac318f97f1d40d777ac498f427b7c417f32651f16574eb441de44730ef5a7299edef57b096137b06ab64a4964aca56d072e7a0c0
7
- data.tar.gz: a698dc1828a99415b4b88b373541ad20b264933cb2d13b0c65b2efd6c4608361b40bb0dca4756f9a518dee3a9e7fa4f8c43e142dfb3a50bba391398f76744bd5
6
+ metadata.gz: 7c05b2af7ca941a5afb52b703f3f0ee315e0ab48ffa87de88c48c5f22bbc1db82f0a819c7e4f2b10e754b6558569d801431e64b00f491e282eadd9885c4f75ac
7
+ data.tar.gz: fc832aaf5f31e2e6b3f51c268f38529f056dc40a0971fb67e962da313634e2c56580eeac23f8d2e94f2f3dcc74ad3d69b0a465724afb7c178501103a5c01d309
@@ -0,0 +1,63 @@
1
+ module Fastlane
2
+ module Actions
3
+ class BuildkitePipelineUploadAction < Action
4
+ DEFAULT_ENV_FILE = File.join('.buildkite', 'shared-pipeline-vars').freeze
5
+
6
+ def self.run(params)
7
+ pipeline_file = params[:pipeline_file]
8
+ env_file = params[:env_file]
9
+ environment = params[:environment]
10
+
11
+ UI.user_error!("Pipeline file not found: #{pipeline_file}") unless File.exist?(pipeline_file)
12
+ UI.user_error!('This action can only be called from a Buildkite CI build') unless ENV['BUILDKITE'] == 'true'
13
+
14
+ UI.message "Adding steps from `#{pipeline_file}` to the current build"
15
+
16
+ if env_file && File.exist?(env_file)
17
+ UI.message(" - Sourcing environment file beforehand: #{env_file}")
18
+
19
+ sh(environment, "source #{env_file.shellescape} && buildkite-agent pipeline upload #{pipeline_file.shellescape}")
20
+ else
21
+ sh(environment, 'buildkite-agent', 'pipeline', 'upload', pipeline_file)
22
+ end
23
+ end
24
+
25
+ def self.description
26
+ # https://buildkite.com/docs/agent/v3/cli-pipeline#uploading-pipelines
27
+ 'Uploads a pipeline to Buildkite, adding all its steps to the current build'
28
+ end
29
+
30
+ def self.available_options
31
+ [
32
+ FastlaneCore::ConfigItem.new(
33
+ key: :pipeline_file,
34
+ description: 'The path to the YAML pipeline file to upload',
35
+ optional: false,
36
+ type: String
37
+ ),
38
+ FastlaneCore::ConfigItem.new(
39
+ key: :env_file,
40
+ description: 'The path to a bash file to be sourced before uploading the pipeline',
41
+ optional: true,
42
+ default_value: DEFAULT_ENV_FILE,
43
+ type: String
44
+ ),
45
+ FastlaneCore::ConfigItem.new(
46
+ key: :environment,
47
+ description: 'Environment variables to load when running `pipeline upload`, to allow for variable substitution in the YAML pipeline',
48
+ type: Hash,
49
+ default_value: {}
50
+ ),
51
+ ]
52
+ end
53
+
54
+ def self.authors
55
+ ['Automattic']
56
+ end
57
+
58
+ def self.is_supported?(platform)
59
+ true
60
+ end
61
+ end
62
+ end
63
+ end
@@ -58,7 +58,7 @@ module Fastlane
58
58
  ),
59
59
  FastlaneCore::ConfigItem.new(
60
60
  key: :buildkite_organization,
61
- env_name: 'BUILDKITE_ORGANIZTION',
61
+ env_name: 'BUILDKITE_ORGANIZATION',
62
62
  description: 'The Buildkite organization that contains your pipeline',
63
63
  type: String
64
64
  ),
@@ -103,10 +103,7 @@ module Fastlane
103
103
  # if there's a callback, make sure it didn't switch branches
104
104
  other_action.ensure_git_branch(branch: "^#{intermediate_branch}/") unless intermediate_branch_created_callback.nil?
105
105
 
106
- base_branch_ref = base_branch.start_with?('origin/') ? base_branch : "origin/#{base_branch}"
107
- head_branch_ref = head_branch.start_with?('origin/') ? head_branch : "origin/#{head_branch}"
108
-
109
- if Fastlane::Helper::GitHelper.point_to_same_commit?(base_branch_ref, head_branch_ref)
106
+ if Fastlane::Helper::GitHelper.point_to_same_commit?(base_branch, head_branch)
110
107
  UI.error("No differences between #{head_branch} and #{base_branch}. Skipping PR creation.")
111
108
  return nil
112
109
  end
@@ -2,15 +2,39 @@ module Fastlane
2
2
  module Actions
3
3
  class IosGenerateStringsFileFromCodeAction < Action
4
4
  def self.run(params)
5
- files = files_matching(paths: params[:paths], exclude: params[:exclude])
6
- flags = [('-q' if params[:quiet]), ('-SwiftUI' if params[:swiftui])].compact
7
- flags += Array(params[:routines]).flat_map { |routine| ['-s', routine] }
8
- cmd = ['genstrings', '-o', params[:output_dir], *flags, *files]
9
- out = Actions.sh_control_output(*cmd, print_command: FastlaneCore::Globals.verbose?, print_command_output: true)
10
- out = out.scrub.strip.split("\n")
11
- errors = out.select { |line| line.include?('genstrings: error: ') }
12
- UI.user_error!(errors.join("\n")) unless !params[:fail_on_error] || errors.empty?
13
- out
5
+ output_encoding = begin
6
+ Encoding.find(params[:output_encoding])
7
+ rescue ArgumentError => e
8
+ UI.user_error!(e.message)
9
+ end
10
+
11
+ Dir.mktmpdir('genstrings-output-') do |tmpdir|
12
+ # Build the command arguments
13
+ files = files_matching(paths: params[:paths], exclude: params[:exclude])
14
+ flags = [
15
+ ('-q' if params[:quiet]),
16
+ ('-SwiftUI' if params[:swiftui]),
17
+ # If no endianness (-bigEndian vs -littleEndian) is specified, genstrings will use endianness of the current OS.
18
+ # Currently, genstrings runs only on macOS, which is little-endian, so this parameter is not strictly necessary.
19
+ # We make it explicit here to raise visibility on the relationship between the endianness of the genstring output and that of the encoding later on.
20
+ '-littleEndian',
21
+ ].compact
22
+ flags += Array(params[:routines]).flat_map { |routine| ['-s', routine] }
23
+ cmd = ['genstrings', '-o', tmpdir, *flags, *files]
24
+
25
+ # Run the genstrings command
26
+ cmd_output = Actions.sh_control_output(*cmd, print_command: FastlaneCore::Globals.verbose?, print_command_output: true)
27
+
28
+ # Extract errors from output, if any
29
+ cmd_output = cmd_output.scrub.strip.split("\n")
30
+ errors = cmd_output.select { |line| line.include?('genstrings: error: ') }
31
+ UI.user_error!(errors.join("\n")) unless !params[:fail_on_error] || errors.empty?
32
+
33
+ # Convert generated files to requested encoding if necessary, and copy to final destination
34
+ post_process_generated_files(source_dir: tmpdir, dest_dir: params[:output_dir], dest_encoding: output_encoding)
35
+
36
+ cmd_output
37
+ end
14
38
  end
15
39
 
16
40
  # Adds the proper `**/*.{m,swift}` to the list of paths
@@ -24,6 +48,7 @@ module Fastlane
24
48
  end
25
49
  end
26
50
 
51
+ # List files matching a list of glob patterns, except the ones matching the list of exclusion patterns
27
52
  def self.files_matching(paths:, exclude:)
28
53
  globbed_paths = paths.map { |p| glob_pattern(p) }
29
54
  Dir.glob(globbed_paths).reject do |file|
@@ -31,6 +56,24 @@ module Fastlane
31
56
  end
32
57
  end
33
58
 
59
+ # Convert the generated files in `source_dir` to the `dest_encoding` if necessary, then copy them to the final `dest_dir`
60
+ def self.post_process_generated_files(source_dir:, dest_dir:, dest_encoding:)
61
+ Dir.each_child(source_dir) do |filename|
62
+ source = File.join(source_dir, filename)
63
+ next if filename.start_with?('.') || !File.file?(source)
64
+
65
+ destination = File.join(dest_dir, filename)
66
+ if dest_encoding.name == 'UTF-16LE'
67
+ # genstrings generates UTF-16 LittleEndian by default, so if that's the requested output encoding, we just copy
68
+ # the file directly, to avoid the read/write dance, reduce memory footprint, and reduce risk of encoding errors on read
69
+ FileUtils.cp(source, destination)
70
+ else
71
+ content = File.read(source, binmode: true, encoding: 'BOM|UTF-16LE')
72
+ File.write(destination, content, binmode: true, encoding: dest_encoding.name)
73
+ end
74
+ end
75
+ end
76
+
34
77
  #####################################################
35
78
  # @!group Documentation
36
79
  #####################################################
@@ -85,6 +128,11 @@ module Fastlane
85
128
  env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_OUTPUT_DIR',
86
129
  description: 'The path to the directory where the generated `.strings` files should be created',
87
130
  type: String),
131
+ FastlaneCore::ConfigItem.new(key: :output_encoding,
132
+ env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_OUTPUT_ENCODING',
133
+ description: 'The encoding to convert the generated files to',
134
+ type: String,
135
+ default_value: 'UTF-16LE'), # The default encoding used by `genstrings` for generated files
88
136
  FastlaneCore::ConfigItem.new(key: :fail_on_error,
89
137
  env_name: 'FL_IOS_GENERATE_STRINGS_FILE_FROM_CODE_FAIL_ON_ERROR',
90
138
  description: 'If true, will fail with user_error! if `genstrings` printed any error while parsing',
@@ -174,20 +174,23 @@ module Fastlane
174
174
  #
175
175
  # @param ref1 [String] the first git reference to check.
176
176
  # @param ref2 [String] the second git reference to check.
177
+ # @param remote_name [String] the name of the remote repository to use (default is 'origin').
178
+ # If nil or empty, no remote prefix will be used.
177
179
  #
178
180
  # @return [Boolean] true if the two references point to the same commit, false otherwise.
179
181
  #
180
- def self.point_to_same_commit?(ref1, ref2)
182
+ def self.point_to_same_commit?(ref1, ref2, remote_name: 'origin')
181
183
  git_repo = Git.open(Dir.pwd)
182
184
 
185
+ ref1_full = remote_name.to_s.empty? ? ref1 : "#{remote_name}/#{ref1}"
186
+ ref2_full = remote_name.to_s.empty? ? ref2 : "#{remote_name}/#{ref2}"
183
187
  begin
184
- ref1_commit = git_repo.gcommit(ref1)
185
- ref2_commit = git_repo.gcommit(ref2)
188
+ ref1_commit = git_repo.gcommit(ref1_full)
189
+ ref2_commit = git_repo.gcommit(ref2_full)
186
190
  rescue StandardError => e
187
- puts "Error: #{e.message}"
191
+ UI.error "Error fetching commits for #{ref1_full} and #{ref2_full}: #{e.message}"
188
192
  return false
189
193
  end
190
-
191
194
  ref1_commit.sha == ref2_commit.sha
192
195
  end
193
196
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fastlane
4
4
  module Wpmreleasetoolkit
5
- VERSION = '12.0.0'
5
+ VERSION = '12.2.0'
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: 12.0.0
4
+ version: 12.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Automattic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-09-03 00:00:00.000000000 Z
11
+ date: 2024-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -406,6 +406,7 @@ files:
406
406
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_update_release_notes.rb
407
407
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_annotate_action.rb
408
408
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_metadata_action.rb
409
+ - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_pipeline_upload_action.rb
409
410
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_trigger_build_action.rb
410
411
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_for_toolkit_updates_action.rb
411
412
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/check_translation_progress.rb