fastlane-plugin-wpmreleasetoolkit 14.11.2 → 15.0.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: 0a1f1e623158a6faef2f63c3376a61d70cdcee25c70ebf91802d0cebdacef0a2
4
- data.tar.gz: af2b3f68f2cc761f05a88c676bad63b12b55b44944052e11fe04b210c3421102
3
+ metadata.gz: d947683766d2a3fddc5ab9ccf7182bc628ca63d839e94ab6633cead85d91fc76
4
+ data.tar.gz: 3278ec05690d03d229b938b711e8e4ecf59fe2945008672ebc81b7a5edbfe555
5
5
  SHA512:
6
- metadata.gz: daf03a722ae1f03c8b9883a7552ca75d575ff059233eed51cb9368686bf4007a816ac193f89a4892f9d1d36ab3fe0d51ad8e09dd2ad2d0301144db006b478258
7
- data.tar.gz: 9c0edbfe34703dbf6dace3a805dc22f639cbd861d8d8f3615129eca857000ce9d516e159bff6413f45c92e2cff5dfd43c9c35a6fedcaef6369f6158e856d2f38
6
+ metadata.gz: 5512d2f282436ade2e641cefb4f5e4b3bb5db9a6c857a1d20841cebf45339c4e4e485e994c6094eb3f1a5eb78a284ef5826edaf0712d51c78b012def1f0bed3a
7
+ data.tar.gz: fa586cd530a3bb5463e3038ae9e057cab05d8166ab9d69aedbc823824f2770e14efc8afb70674fd66a4e6bc5790e6dfe753a9469eecdd6d1a809176bd9c7a4d4
@@ -25,6 +25,8 @@ module Fastlane
25
25
  config_file_path: config_file_path
26
26
  )
27
27
  rescue StandardError => e
28
+ raise if params[:fail_on_error]
29
+
28
30
  error_msg = "❌ Error computing the list of PRs since #{previous_tag || 'last release'}: `#{e.message}`"
29
31
  UI.important(error_msg)
30
32
  error_msg # Use error message as GitHub Release body to help us be aware of what went wrong.
@@ -102,6 +104,15 @@ module Fastlane
102
104
  'See https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuration-options',
103
105
  optional: true,
104
106
  type: String),
107
+ FastlaneCore::ConfigItem.new(key: :fail_on_error,
108
+ description: 'Whether to fail the lane if the changelog cannot be computed. ' \
109
+ 'When `false` (the default), the error message is returned as the changelog itself, ' \
110
+ 'so that it ends up visible in the GitHub Release body. ' \
111
+ 'Set this to `true` if the caller publishes the release only after this action succeeds, ' \
112
+ 'and would rather stop than publish a release whose notes are an error message',
113
+ optional: true,
114
+ default_value: false,
115
+ type: Boolean),
105
116
  Fastlane::Helper::GithubHelper.github_token_config_item,
106
117
  ]
107
118
  end
@@ -15,10 +15,22 @@ module Fastlane
15
15
  end
16
16
 
17
17
  # Set up by loading the .env file with the given name.
18
+ #
19
+ # When `mutate_env` is true (the default), values from the .env file are
20
+ # layered into the process `ENV` using no-override semantics: keys already
21
+ # set in `ENV` (e.g. by CI) win. This lets fastlane actions that look up
22
+ # values via `ENV.fetch(...)` for their `default_value:` find them without
23
+ # the caller having to thread them through explicitly.
24
+ #
25
+ # Pass `mutate_env: false` to keep `ENV` pristine — values are still
26
+ # accessible via `get_required_env!`, but only through this instance.
27
+ # Useful for tests that want isolation, or for callers that prefer to
28
+ # control `ENV` themselves.
18
29
  def initialize(
19
30
  env_file_name:,
20
31
  env_file_folder: File.join(Dir.home, '.a8c-apps'),
21
32
  example_env_file_path: 'fastlane/example.env',
33
+ mutate_env: true,
22
34
  print_error_lambda: ->(message) { FastlaneCore::UI.user_error!(message) },
23
35
  print_warning_lambda: ->(message) { FastlaneCore::UI.important(message) }
24
36
  )
@@ -31,10 +43,30 @@ module Fastlane
31
43
  @print_warning_lambda.call("Warning: env file not found at #{@env_path}. Environment variables may not be loaded.")
32
44
  end
33
45
 
34
- # Parse rather than load so we don't mutate the global ENV. Each instance
35
- # gets its own view, and values from the process environment (e.g. set by
36
- # CI) still take precedence — see `env_value`.
37
- @loaded_env = File.exist?(@env_path) ? Dotenv.parse(@env_path) : {}
46
+ unless mutate_env
47
+ @loaded_env = File.exist?(@env_path) ? Dotenv.parse(@env_path) : {}
48
+ @mutations = {}
49
+ return
50
+ end
51
+
52
+ # `load` rather than `parse` so interpolated values (`B=${A}`) resolve
53
+ # against the process `ENV`; `parse` resolves them against the file's own values.
54
+ env_before = ENV.to_h
55
+ @loaded_env = File.exist?(@env_path) ? Dotenv.load(@env_path) : {}
56
+ # Records the value this instance wrote for each key it added. On restore,
57
+ # we delete only if `ENV[key]` still matches — if a later caller overwrote
58
+ # it, their value is left alone.
59
+ @mutations = ENV.to_h.reject { |key, _| env_before.key?(key) }
60
+ end
61
+
62
+ # Remove from `ENV` any keys this instance added via `mutate_env: true`,
63
+ # but only if the value is still the one we wrote. Keys that a later
64
+ # caller has overwritten are left untouched.
65
+ # Idempotent — calling more than once is safe. Used by `reset!` and
66
+ # available for callers that want to roll back manually.
67
+ def restore_env!
68
+ @mutations.each { |key, value| ENV.delete(key) if ENV[key] == value }
69
+ @mutations = {}
38
70
  end
39
71
 
40
72
  # Use this instead of getting values from `ENV` directly. It will throw an error if the requested value is missing or empty.
@@ -135,8 +167,10 @@ module Fastlane
135
167
  default!.require_env_vars!(*keys)
136
168
  end
137
169
 
138
- # Clears the default instance, useful for test teardown.
170
+ # Clears the default instance, useful for test teardown. Also rolls back
171
+ # any `ENV` mutations the default instance performed via `mutate_env`.
139
172
  def self.reset!
173
+ @default&.restore_env!
140
174
  @default = nil
141
175
  end
142
176
 
@@ -267,13 +267,13 @@ module Fastlane
267
267
  #
268
268
  # @param [String] branch_name The name of the remote branch to delete.
269
269
  # @param [String] remote_name The name of the remote to delete the branch from. Defaults to 'origin'
270
- # @return [Boolean] true if the branch was deleted, false if not (e.g. no such local branch existed in the first place)
270
+ # @return [Boolean] true if the branch was deleted, false if it did not exist on the remote
271
271
  #
272
272
  def self.delete_remote_branch_if_exists!(branch_name, remote_name: 'origin')
273
- git_repo = Git.open(Dir.pwd)
274
- return false unless git_repo.branches.any? { |b| b.remote&.name == remote_name && b.name == branch_name }
273
+ return false unless branch_exists_on_remote?(branch_name: branch_name, remote_name: remote_name)
275
274
 
276
- git_repo.push(remote_name, branch_name, delete: true)
275
+ Git.open(Dir.pwd).push(remote_name, branch_name, delete: true)
276
+ true
277
277
  end
278
278
 
279
279
  # Checks whether a given path is ignored by Git, relying on Git's `check-ignore` under the hood.
@@ -3,6 +3,6 @@
3
3
  module Fastlane
4
4
  module Wpmreleasetoolkit
5
5
  NAME = 'fastlane-plugin-wpmreleasetoolkit'
6
- VERSION = '14.11.2'
6
+ VERSION = '15.0.0'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-wpmreleasetoolkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.11.2
4
+ version: 15.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Automattic
@@ -271,7 +271,6 @@ files:
271
271
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_localize_libs_action.rb
272
272
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb
273
273
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_validate_lib_strings_action.rb
274
- - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_preflight.rb
275
274
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_avd_action.rb
276
275
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_xml_release_notes.rb
277
276
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb
@@ -324,7 +323,6 @@ files:
324
323
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/configure/configure_validate_action.rb
325
324
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_development_certificates_to_provisioning_profiles.rb
326
325
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/add_devices_to_provisioning_profiles.rb
327
- - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_preflight.rb
328
326
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb
329
327
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_download_strings_files_from_glotpress.rb
330
328
  - lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_extract_keys_from_strings_files.rb
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fastlane
4
- module Actions
5
- class AndroidBuildPreflightAction < Action
6
- def self.run(params)
7
- # Validate mobile configuration secrets
8
- other_action.configure_apply
9
-
10
- # Check gems and pods are up to date. This will exit if it fails
11
- begin
12
- Action.sh('bundle check')
13
- rescue StandardError
14
- UI.user_error!("You should run 'bundle install' to make sure gems are up to date")
15
- raise
16
- end
17
-
18
- begin
19
- Action.sh('command -v bundletool > /dev/null')
20
- rescue StandardError
21
- UI.user_error!("bundletool is required to build the APKs. Install it with 'brew install bundletool'")
22
- raise
23
- end
24
- end
25
-
26
- #####################################################
27
- # @!group Documentation
28
- #####################################################
29
-
30
- def self.description
31
- 'Clean the environment to ensure a safe build'
32
- end
33
-
34
- def self.details
35
- 'Clean the environment to ensure a safe build'
36
- end
37
-
38
- def self.available_options
39
- end
40
-
41
- def self.output
42
- end
43
-
44
- def self.return_value
45
- end
46
-
47
- def self.authors
48
- ['Automattic']
49
- end
50
-
51
- def self.is_supported?(platform)
52
- platform == :android
53
- end
54
- end
55
- end
56
- end
@@ -1,79 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Fastlane
4
- module Actions
5
- class IosBuildPreflightAction < Action
6
- def self.run(params)
7
- # Validate mobile configuration secrets
8
- other_action.configure_apply
9
-
10
- Action.sh("cd .. && rm -rf #{params[:derived_data_path]}")
11
-
12
- # Verify that ImageMagick exists on this machine and can be called from the command-line.
13
- # Internal Builds use it to generate the App Icon as part of the build process
14
- begin
15
- Action.sh('which convert')
16
- rescue StandardError
17
- UI.user_error!("Couldn't find ImageMagick. Please install it by running `brew install imagemagick`")
18
- raise
19
- end
20
-
21
- # Verify that Ghostscript exists on this machine and can be called from the command-line.
22
- # Internal Builds use it to generate the App Icon as part of the build process
23
- begin
24
- Action.sh('which gs')
25
- rescue StandardError
26
- UI.user_error!("Couldn't find Ghostscript. Please install it by running `brew install ghostscript`")
27
- raise
28
- end
29
-
30
- # Check gems and pods are up to date. This will exit if it fails
31
- begin
32
- Action.sh('bundle check')
33
- rescue StandardError
34
- UI.user_error!("You should run 'rake dependencies' to make sure gems are up to date")
35
- raise
36
- end
37
-
38
- other_action.cocoapods
39
- end
40
-
41
- #####################################################
42
- # @!group Documentation
43
- #####################################################
44
-
45
- def self.description
46
- 'Clean the environment to ensure a safe build'
47
- end
48
-
49
- def self.details
50
- 'Clean the environment to ensure a safe build'
51
- end
52
-
53
- def self.available_options
54
- [
55
- FastlaneCore::ConfigItem.new(
56
- key: :derived_data_path,
57
- description: "The path to the DerivedData directory for the project. Should match what's used in the `gym` action",
58
- type: String,
59
- default_value: '~/Library/Developer/Xcode/DerivedData'
60
- ),
61
- ]
62
- end
63
-
64
- def self.output
65
- end
66
-
67
- def self.return_value
68
- end
69
-
70
- def self.authors
71
- ['Automattic']
72
- end
73
-
74
- def self.is_supported?(platform)
75
- %i[ios mac].include?(platform)
76
- end
77
- end
78
- end
79
- end