fastlane-plugin-wpmreleasetoolkit 13.1.2 → 13.2.0

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: 58554aababcf0bef878ca3af98c8380c5a90f03ece833bfb3686e12f9f34bbf1
4
- data.tar.gz: 65889ef19ebb737a8bc141c05ff86cf86974af4cc63c5c5735d4b03faf263380
3
+ metadata.gz: b96cfe534c654f80942c7623819cac09dd3241fc5ba706a21c0ed3db1eef26aa
4
+ data.tar.gz: 22a84da84041c275c535beac3f347a432a793b4dc3690df855c29771e78b8483
5
5
  SHA512:
6
- metadata.gz: 89f80c2ff710910c5c24c4971bcd44a508d33db3f6bb6944fd37a337202b2c320175fd7a844e1f293900831e92258e355680b8ddbebf47a0a5dee27003df1c92
7
- data.tar.gz: 0a7a0c11bdbd423900d8bfbbc0f4b03740480992984a56138c57fd018d574204af27a5b9cd44a43598285cbe128b2d78d895ee66eeaa79a4cc78909df4d28d3b
6
+ metadata.gz: 5d2ef6a47af19fb7370eb894fa9db53d39a1688bc8c862269243702e8f91ebbf68060478653311b5989d46c39ce86e1308675ed4153b9aecb9350e5bc45f1214
7
+ data.tar.gz: 6833e063d42b40d2f6aa2f6f918b8ecab482f8fdca7ca28871b9f0b024f8250a7ce21339f2844c8d4ed23ac29783126491db97aa34204fcb790efff7eb3f69e1
@@ -0,0 +1,171 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+
5
+ module Fastlane
6
+ module Actions
7
+ class BuildkiteAddTriggerStepAction < Action
8
+ BUILDKITE_ENV_ERROR_MESSAGE = 'This action can only be run from within a Buildkite build'
9
+
10
+ def self.run(params)
11
+ unless ENV.key?('BUILDKITE_JOB_ID')
12
+ UI.user_error!(BUILDKITE_ENV_ERROR_MESSAGE)
13
+ end
14
+
15
+ # Extract parameters
16
+ pipeline_file = params[:pipeline_file]
17
+ build_name = File.basename(pipeline_file, '.yml')
18
+ message = params[:message] || build_name
19
+ branch = params[:branch] || sh('git', 'rev-parse', '--abbrev-ref', 'HEAD').strip
20
+ environment = params[:environment] || {}
21
+ buildkite_pipeline_slug = params[:buildkite_pipeline_slug]
22
+ async = params[:async]
23
+ label = params[:label] || ":buildkite: Trigger #{build_name} on #{branch}"
24
+ depends_on = params[:depends_on]&.then { |v| v.empty? ? nil : Array(v) }
25
+
26
+ # Add the PIPELINE environment variable to the environment hash
27
+ environment = environment.merge('PIPELINE' => pipeline_file)
28
+
29
+ # Create the trigger step YAML
30
+ trigger_yaml = {
31
+ 'steps' => [
32
+ {
33
+ 'trigger' => buildkite_pipeline_slug,
34
+ 'label' => label,
35
+ 'async' => async,
36
+ 'build' => {
37
+ 'branch' => branch,
38
+ 'message' => message,
39
+ 'env' => environment
40
+ },
41
+ 'depends_on' => depends_on
42
+ }.compact,
43
+ ]
44
+ }.to_yaml
45
+
46
+ # Use buildkite-agent to upload the pipeline
47
+ _stdout, stderr, status = Open3.capture3('buildkite-agent', 'pipeline', 'upload', stdin_data: trigger_yaml)
48
+
49
+ # Check for errors
50
+ UI.user_error!("Failed to upload pipeline: #{stderr}") unless status.success?
51
+
52
+ # Log success
53
+ UI.success("Added a trigger step to the current Buildkite build to start a new build for #{pipeline_file} on branch #{branch}")
54
+ end
55
+
56
+ def self.description
57
+ 'Adds a trigger step to the current Buildkite pipeline to start a new build from this one'
58
+ end
59
+
60
+ def self.details
61
+ <<~DETAILS
62
+ This action adds a `trigger` step to the current Buildkite build, to start a separate build from the current one.
63
+
64
+ This is slightly different from `buildkite-agent pipeline upload`-ing the YAML steps of the build directly to the current build,
65
+ as this approach ensures the triggered build starts from a clean and independent context.
66
+ - This is particularly important if the build being triggered rely on the fact that the current build pushed new commits
67
+ to the Git branch and we want the new build's steps to start from the new commit.
68
+ - This is also necessary for cases where we run builds on a mirror of the original Git repo (e.g. for pipelines of repos hosted
69
+ in a private GitHub Enterprise server, mirrored on GitHub.com for CI building purposes) and we want the new build being triggered
70
+ to initiate a new sync of the Git repo as part of the CI build bootstrap process, to get the latest commits.
71
+ DETAILS
72
+ end
73
+
74
+ def self.available_options
75
+ [
76
+ FastlaneCore::ConfigItem.new(
77
+ key: :buildkite_pipeline_slug,
78
+ env_name: 'BUILDKITE_PIPELINE_SLUG',
79
+ description: 'The slug of the Buildkite pipeline to trigger. Defaults to the same slug as the current pipeline, so usually not necessary to provide explicitly',
80
+ type: String,
81
+ optional: false # But most likely to be auto-provided by the ENV var of the current build and thus not needed to be provided explicitly
82
+ ),
83
+ FastlaneCore::ConfigItem.new(
84
+ key: :label,
85
+ description: 'Custom label for the trigger step. If not provided, defaults to ":buildkite: Trigger {`pipeline_file`\'s basename} on {branch}"',
86
+ type: String,
87
+ optional: true
88
+ ),
89
+ FastlaneCore::ConfigItem.new(
90
+ key: :pipeline_file,
91
+ description: 'The path (relative to `.buildkite/`) to the pipeline YAML file to use for the triggered build',
92
+ type: String,
93
+ optional: false
94
+ ),
95
+ FastlaneCore::ConfigItem.new(
96
+ key: :branch,
97
+ description: 'The branch to trigger the build on. Defaults to the Git branch currently checked out at the time of running the action (which is not necessarily the same as the `BUILDKITE_BRANCH` the current build initially started on)',
98
+ type: String,
99
+ optional: true
100
+ ),
101
+ FastlaneCore::ConfigItem.new(
102
+ key: :message,
103
+ description: 'The message / title to use for the triggered build. If not provided, defaults to the `pipeline_file`\'s basename',
104
+ type: String,
105
+ optional: true
106
+ ),
107
+ FastlaneCore::ConfigItem.new(
108
+ key: :environment,
109
+ description: 'Environment variables to pass to the triggered build (in addition to the PIPELINE={pipeline_file} that will be automatically injected)',
110
+ type: Hash,
111
+ default_value: {},
112
+ optional: true
113
+ ),
114
+ FastlaneCore::ConfigItem.new(
115
+ key: :async,
116
+ description: 'Whether to trigger the build asynchronously (true) or wait for it to complete (false). Defaults to false',
117
+ type: Boolean,
118
+ default_value: false
119
+ ),
120
+ FastlaneCore::ConfigItem.new(
121
+ key: :depends_on,
122
+ env_name: 'BUILDKITE_STEP_KEY', # This is the env var that Buildkite sets for the current step
123
+ description: 'The steps to depend on before triggering the build. Defaults to the current step this action is called from, if said step has a `key:` attribute set. Use an empty array to explicitly not depend on any step even if the current step has a `key`',
124
+ type: Array,
125
+ default_value: [],
126
+ optional: true
127
+ ),
128
+ ]
129
+ end
130
+
131
+ def self.return_value
132
+ 'Returns true if the pipeline was successfully uploaded. Throws a `user_error!` if it failed to upload the `trigger` step to the current build'
133
+ end
134
+
135
+ def self.authors
136
+ ['Automattic']
137
+ end
138
+
139
+ def self.is_supported?(platform)
140
+ true
141
+ end
142
+
143
+ def self.example_code
144
+ [
145
+ <<~CODE,
146
+ # Use default/inferred values for most parameters
147
+ buildkite_add_trigger_step(
148
+ pipeline_file: "release-build.yml",
149
+ environment: { "RELEASE_VERSION" => "1.2.3" },
150
+ )
151
+ CODE
152
+ <<~CODE,
153
+ # Use custom values for most parameters
154
+ buildkite_add_trigger_step(
155
+ label: "🚀 Trigger Release Build",
156
+ pipeline_file: "release-build.yml",
157
+ branch: "release/1.2.3",
158
+ message: "Release Build (123)",
159
+ environment: { "RELEASE_VERSION" => "1.2.3" },
160
+ async: false,
161
+ )
162
+ CODE
163
+ ]
164
+ end
165
+
166
+ def self.category
167
+ :building
168
+ end
169
+ end
170
+ end
171
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Fastlane
4
4
  module Wpmreleasetoolkit
5
- VERSION = '13.1.2'
5
+ VERSION = '13.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: 13.1.2
4
+ version: 13.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: 2025-04-15 00:00:00.000000000 Z
11
+ date: 2025-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -404,6 +404,7 @@ files:
404
404
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_send_app_size_metrics.rb
405
405
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_shutdown_emulator_action.rb
406
406
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_update_release_notes.rb
407
+ - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_add_trigger_step_action.rb
407
408
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_annotate_action.rb
408
409
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_metadata_action.rb
409
410
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/common/buildkite_pipeline_upload_action.rb