Class: Fastlane::Actions::AndroidHotfixPrechecksAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



69
70
71
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb', line 69

def self.authors
  ['Automattic']
end

.available_optionsObject



49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb', line 49

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :version_name,
                                 env_name: 'FL_ANDROID_HOTFIX_PRECHECKS_VERSION',
                                 description: 'The hotfix version number to create',
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :skip_confirm,
                                 env_name: 'FL_ANDROID_HOTFIX_PRECHECKS_SKIPCONFIRM',
                                 description: 'Skips confirmation',
                                 type: Boolean,
                                 default_value: false),
  ]
end

.descriptionObject



41
42
43
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb', line 41

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

.detailsObject



45
46
47
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb', line 45

def self.details
  'Checks out a new branch from a tag and updates tags'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb', line 73

def self.is_supported?(platform)
  platform == :android
end

.outputObject



63
64
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb', line 63

def self.output
end

.return_valueObject



66
67
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb', line 66

def self.return_value
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
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb', line 4

def self.run(params)
  UI.message "Skip confirm: #{params[:skip_confirm]}"
  UI.message ''

  require_relative '../../helper/android/android_version_helper'
  require_relative '../../helper/android/android_git_helper'

  # Evaluate previous tag
  new_ver = params[:version_name]
  prev_ver = Fastlane::Helper::Android::VersionHelper.calc_prev_hotfix_version_name(new_ver)

  # Confirm
  message = "Requested Hotfix version: #{new_ver}\n"
  message << "Branching from tag: #{prev_ver}\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 tags
  UI.crash!("Version #{new_ver} already exists! Abort!") if other_action.git_tag_exists(tag: new_ver)

  UI.crash!("Version #{prev_ver} is not tagged! Can't branch. Abort!") unless other_action.git_tag_exists(tag: prev_ver)

  # Check local repo status
  other_action.ensure_git_status_clean

  # Return the current version
  prev_ver
end