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



106
107
108
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb', line 106

def self.authors
  ['Automattic']
end

.available_optionsObject



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
92
93
94
95
96
97
98
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb', line 59

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: %i[project_name
                                                         project_root_folder
                                                         version_properties_path]),
    FastlaneCore::ConfigItem.new(key: :version_properties_path,
                                 description: 'Path to the version.properties file',
                                 type: String,
                                 optional: true,
                                 conflicting_options: %i[build_gradle_path
                                                         project_name
                                                         project_root_folder]),
    Fastlane::Helper::Deprecated.project_root_folder_config_item,
    Fastlane::Helper::Deprecated.project_name_config_item,
  ]
end

.descriptionObject



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

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

.detailsObject



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

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


110
111
112
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb', line 110

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

.outputObject



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

def self.output
end

.return_valueObject



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

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
45
# 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]

  Fastlane::Helper::GitHelper.ensure_on_branch!('release') unless other_action.is_ci

  project_root_folder = params[:project_root_folder]
  project_name = params[:project_name]
  build_gradle_path = params[:build_gradle_path] || (File.join(project_root_folder || '.', project_name, 'build.gradle') unless project_name.nil?)
  version_properties_path = params[:version_properties_path] || File.join(project_root_folder || '.', 'version.properties')

  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