Class: Fastlane::Actions::IosBetabuildPrechecksAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



88
89
90
91
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb', line 88

def self.authors
  # So no one will ever forget your contribution to fastlane :) You are awesome btw!
  ['Automattic']
end

.available_optionsObject



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb', line 61

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :base_version,
                                 env_name: 'FL_IOS_BETABUILD_PRECHECKS_BASE_VERSION',
                                 description: 'The version to work on', # a short description of this parameter
                                 is_string: true,
                                 optional: true), # true: verifies the input is a string, false: every kind of value),
    FastlaneCore::ConfigItem.new(key: :skip_confirm,
                                 env_name: 'FL_IOS_BETABUILD_PRECHECKS_SKIPCONFIRM',
                                 description: 'Skips confirmation',
                                 is_string: false, # true: verifies the input is a string, false: every kind of value
                                 default_value: false), # the default value if the user didn't provide one
    FastlaneCore::ConfigItem.new(key: :default_branch,
                                 env_name: 'FL_RELEASE_TOOLKIT_DEFAULT_BRANCH',
                                 description: 'Default branch of the repository',
                                 type: String,
                                 default_value: Fastlane::Helper::GitHelper::DEFAULT_GIT_BRANCH),
  ]
end

.descriptionObject



53
54
55
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb', line 53

def self.description
  'Runs some prechecks before preparing for a new test build'
end

.detailsObject



57
58
59
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb', line 57

def self.details
  'Updates the relevant release branch, checks the app version and ensure the branch is clean'
end

.get_user_build_version(version, message) ⇒ Object



42
43
44
45
46
47
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb', line 42

def self.get_user_build_version(version, message)
  UI.user_error!("Release branch for version #{version} doesn't exist. Abort.") unless Fastlane::Helper::GitHelper.checkout_and_pull(release: version)
  build_version = Fastlane::Helper::Ios::VersionHelper.get_build_version
  message << "Looking at branch release/#{version} as requested by user. Detected version: #{build_version}.\n"
  build_version
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb', line 93

def self.is_supported?(platform)
  [:ios, :mac].include?(platform)
end

.outputObject



81
82
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb', line 81

def self.output
end

.return_valueObject



84
85
86
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb', line 84

def self.return_value
  # If you method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb', line 4

def self.run(params)
  UI.message "Skip confirm: #{params[:skip_confirm]}"
  UI.message "Work on version: #{params[:base_version]}" unless params[:base_version].nil?

  require_relative '../../helper/ios/ios_version_helper'
  require_relative '../../helper/ios/ios_git_helper'

  # Checkout default branch and update
  default_branch = params[:default_branch]
  Fastlane::Helper::GitHelper.checkout_and_pull(default_branch)

  # Check versions
  build_version = Fastlane::Helper::Ios::VersionHelper.get_build_version
  message = "The following current version has been detected: #{build_version}\n"

  # Check branch
  app_version = Fastlane::Helper::Ios::VersionHelper.get_public_version
  UI.user_error!("#{message}Release branch for version #{app_version} doesn't exist. Abort.") unless !params[:base_version].nil? || Fastlane::Helper::GitHelper.checkout_and_pull(release: app_version)

  # Check user overwrite
  build_version = get_user_build_version(params[:base_version], message) unless params[:base_version].nil?
  next_version = Fastlane::Helper::Ios::VersionHelper.calc_next_build_version(build_version)

  # Verify
  message << "Updating branch to version: #{next_version}.\n"
  if params[:skip_confirm]
    UI.message(message)
  else
    UI.user_error!('Aborted by user request') unless UI.confirm("#{message}Do you want to continue?")
  end

  # Check local repo status
  other_action.ensure_git_status_clean()

  # Return the current version
  build_version
end