Class: Fastlane::Actions::AndroidBumpVersionHotfixAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



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

def self.authors
  ['Automattic']
end

.available_optionsObject



55
56
57
58
59
60
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_hotfix.rb', line 55

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :version_name,
                                 env_name: 'FL_ANDROID_BUMP_VERSION_HOTFIX_VERSION',
                                 description: 'The version name for the hotfix',
                                 type: String),
    FastlaneCore::ConfigItem.new(key: :version_code,
                                 env_name: 'FL_ANDROID_BUMP_VERSION_HOTFIX_CODE',
                                 description: 'The version code for the hotfix',
                                 type: Integer),
    FastlaneCore::ConfigItem.new(key: :previous_version_name,
                                 env_name: 'FL_ANDROID_BUMP_VERSION_HOTFIX_PREVIOUS_VERSION',
                                 description: 'The version to branch from',
                                 type: String),
    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



47
48
49
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb', line 47

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

.detailsObject



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

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

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


86
87
88
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb', line 86

def self.is_supported?(platform)
  platform == :android
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
# File 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb', line 4

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

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

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

  Fastlane::Helper::GitHelper.create_branch("release/#{params[:version_name]}", from: params[:previous_version_name])

  current_version = Fastlane::Helper::Android::VersionHelper.get_release_version(
    build_gradle_path: build_gradle_path,
    version_properties_path: version_properties_path
  )
  new_version = Fastlane::Helper::Android::VersionHelper.calc_next_hotfix_version(params[:version_name], params[:version_code]) # NOTE: this just puts the name/code values in a tuple, unchanged (no actual calc/bumping)
  new_release_branch = "release/#{params[:version_name]}"

  name_key = Fastlane::Helper::Android::VersionHelper::VERSION_NAME
  code_key = Fastlane::Helper::Android::VersionHelper::VERSION_CODE
  UI.message("Current version: #{current_version[name_key]} (#{current_version[code_key]})")
  UI.message("New hotfix version: #{new_version[name_key]} (#{new_version[code_key]})")
  UI.message("Release branch: #{new_release_branch}")

  UI.message 'Updating app version...'
  Fastlane::Helper::Android::VersionHelper.update_versions(
    new_version,
    nil,
    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
  )

  UI.message 'Done.'
end