Skip to content

Commit 0a5c310

Browse files
committed
Add auto-check for toolkit updates
1 parent 13251a2 commit 0a5c310

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

fastlane/Fastfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,27 @@ def get_required_env(key)
1717
ENV[key]
1818
end
1919

20+
def check_toolkit_update
21+
plugin_name = 'fastlane-plugin-wpmreleasetoolkit'
22+
UI.message('Checking for new version of the release toolkit...')
23+
sh('bundle', 'outdated', plugin_name, '--porcelain') do |status, _, _|
24+
break if status.success?
25+
26+
UI.important('The Release Toolkit you are using seems to be outdated. We suggest you to update to the latest version ASAP.')
27+
if UI.interactive? && UI.confirm("Run \`bundle update #{plugin_name}\` now?")
28+
sh('bundle', 'update', plugin_name)
29+
UI.abort_with_message!("#{plugin_name} updated. Please restart your previous invocation of the \`#{lane_context[SharedValues::LANE_NAME]}\` lane to use the new toolkit.")
30+
end
31+
end
32+
end
33+
2034
before_all do |lane|
2135
# Skip these checks/steps for test lane (not needed for testing)
2236
next if lane == :test_without_building
2337

38+
# Ensure we use the latest version of the toolkit
39+
check_toolkit_update unless is_ci || ENV['FASTLANE_SKIP_TOOLKIT_UPDATE_CHECK']
40+
2441
# Check that the env files exist
2542
unless is_ci || File.file?(USER_ENV_FILE_PATH)
2643
UI.user_error!("~/.wcios-env.default not found: Please copy env/user.env-example to #{USER_ENV_FILE_PATH} and fill in the values")

0 commit comments

Comments
 (0)