Class: Fastlane::Actions::AndroidBuildPrechecksAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



99
100
101
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb', line 99

def self.authors
  ['Automattic']
end

.available_optionsObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb', line 58

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :skip_confirm,
                                 env_name: 'FL_ANDROID_BUILD_PRECHECKS_SKIP_CONFIRM',
                                 description: 'True to avoid the system ask for confirmation',
                                 type: Boolean,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :alpha,
                                 env_name: 'FL_ANDROID_BUILD_PRECHECKS_ALPHA_BUILD',
                                 description: 'True if this is for an alpha build',
                                 type: Boolean,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :beta,
                                 env_name: 'FL_ANDROID_BUILD_PRECHECKS_BETA_BUILD',
                                 description: 'True if this is for a beta build',
                                 type: Boolean,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :final,
                                 env_name: 'FL_ANDROID_BUILD_PRECHECKS_FINAL_BUILD',
                                 description: 'True if this is for a final build',
                                 type: Boolean,
                                 default_value: false),
    FastlaneCore::ConfigItem.new(key: :build_gradle_path,
                                 description: 'Path to the build.gradle file',
                                 type: String,
                                 optional: true,
                                 conflicting_options: [:version_properties_path]),
    FastlaneCore::ConfigItem.new(key: :version_properties_path,
                                 description: 'Path to the version.properties file',
                                 type: String,
                                 optional: true,
                                 conflicting_options: [:build_gradle_path]),
  ]
end

.descriptionObject



50
51
52
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb', line 50

def self.description
  'Runs some prechecks before the build'
end

.detailsObject



54
55
56
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb', line 54

def self.details
  'Runs some prechecks before the build'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb', line 103

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

.outputObject



93
94
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb', line 93

def self.output
end

.return_valueObject



96
97
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb', line 96

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
36
37
38
39
40
41
42
43
44
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb', line 4

def self.run(params)
  require_relative '../../helper/android/android_version_helper'
  require_relative '../../helper/git_helper'

  UI.user_error!("Can't build beta and final at the same time!") if params[:final] && params[:beta]

  # Verify that the current branch is a release branch. Notice that `ensure_git_branch` expects a RegEx parameter
  ensure_git_branch(branch: '^release/') unless other_action.is_ci

  build_gradle_path = params[:build_gradle_path]
  version_properties_path = params[:version_properties_path]

  message = ''
  unless !params[:beta] && !params[:final]
    beta_version = Fastlane::Helper::Android::VersionHelper.get_release_version(
      build_gradle_path: build_gradle_path,
      version_properties_path: version_properties_path
    )
  end
  if params[:alpha]
    alpha_version = Fastlane::Helper::Android::VersionHelper.get_alpha_version(
      build_gradle_path: build_gradle_path,
      version_properties_path: version_properties_path
    )
  end

  UI.user_error!("Can't build a final release out of this branch because it's configured as a beta release!") if params[:final] && Fastlane::Helper::Android::VersionHelper.is_beta_version?(beta_version)

  message << "Building version #{beta_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{beta_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}) (for upload to Release Channel)\n" if params[:final]
  message << "Building version #{beta_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{beta_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}) (for upload to Beta Channel)\n" if params[:beta]
  message << "Building version #{alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_NAME]}(#{alpha_version[Fastlane::Helper::Android::VersionHelper::VERSION_CODE]}) (for upload to Alpha Channel)\n" if params[:alpha]

  UI.important(message)

  if !options[:skip_confirm] && !UI.confirm('Do you want to continue?')
    UI.user_error!('Aborted by user request')
  end

  # Check local repo status
  other_action.ensure_git_status_clean unless other_action.is_ci
end