Class: Fastlane::Actions::AndroidBumpVersionBetaAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



88
89
90
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb', line 88

def self.authors
  ['Automattic']
end

.available_optionsObject



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

def self.available_options
  [
    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



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

def self.description
  'Bumps the version of the app for a new beta.'
end

.detailsObject



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

def self.details
  'Bumps the version of the app for a new beta.'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


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

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

.outputObject



82
83
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb', line 82

def self.output
end

.return_valueObject



85
86
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb', line 85

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
46
47
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb', line 4

def self.run(params)
  UI.message 'Bumping app release version...'

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

  Fastlane::Helper::GitHelper.ensure_on_branch!('release')

  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')

  current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(
    build_gradle_path: build_gradle_path,
    version_properties_path: version_properties_path
  )
  current_version_alpha = Fastlane::Helper::Android::VersionHelper.get_alpha_version(
    build_gradle_path: build_gradle_path,
    version_properties_path: version_properties_path
  )
  new_version_beta = Fastlane::Helper::Android::VersionHelper.calc_next_beta_version(current_version, current_version_alpha)
  new_version_alpha = current_version_alpha.nil? ? nil : Fastlane::Helper::Android::VersionHelper.calc_next_alpha_version(new_version_beta, current_version_alpha)

  vname = Fastlane::Helper::Android::VersionHelper::VERSION_NAME
  vcode = Fastlane::Helper::Android::VersionHelper::VERSION_CODE
  UI.message("Current version: #{current_version[vname]}(#{current_version[vcode]})")
  UI.message("Current alpha version: #{current_version_alpha[vname]}(#{current_version_alpha[vcode]})") unless current_version_alpha.nil?
  UI.message("New beta version: #{new_version_beta[vname]}(#{new_version_beta[vcode]})")
  UI.message("New alpha version: #{new_version_alpha[vname]}(#{new_version_alpha[vcode]})") unless current_version_alpha.nil?

  UI.message 'Updating app version...'
  Fastlane::Helper::Android::VersionHelper.update_versions(
    new_version_beta,
    new_version_alpha,
    version_properties_path: version_properties_path
  )
  UI.message 'Done!'

  Fastlane::Helper::Android::GitHelper.commit_version_bump(
    build_gradle_path: build_gradle_path,
    version_properties_path: version_properties_path
  )
end