Class: Fastlane::Actions::GetVersionNumberFromGitBranchAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/versioning/actions/get_version_number_from_git_branch.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



37
38
39
# File 'lib/fastlane/plugin/versioning/actions/get_version_number_from_git_branch.rb', line 37

def self.authors
  ["SiarheiFedartsou"]
end

.available_optionsObject



27
28
29
30
31
32
33
34
35
# File 'lib/fastlane/plugin/versioning/actions/get_version_number_from_git_branch.rb', line 27

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :pattern,
                       env_name: "FL_VERSION_NUMBER_FROM_GIT_BRANCH_PATTERN",
                       description: "Pattern for branch name, should contain # character in place of version number",
                       default_value: 'release-#',
                       is_string: true)
  ]
end

.descriptionObject



23
24
25
# File 'lib/fastlane/plugin/versioning/actions/get_version_number_from_git_branch.rb', line 23

def self.description
  "Extract version number from git branch name"
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/fastlane/plugin/versioning/actions/get_version_number_from_git_branch.rb', line 41

def self.is_supported?(platform)
  %i[ios mac android].include? platform
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fastlane/plugin/versioning/actions/get_version_number_from_git_branch.rb', line 4

def self.run(params)
  if Helper.test?
    branch = 'releases/release-1.3.5'
  else
    branch = Actions.git_branch
  end

  pattern = params[:pattern].dup
  pattern["#"] = "(.*)"

  match = Regexp.new(pattern).match(branch)
  UI.user_error!("Cannot find version number in git branch '#{branch}' by pattern '#{params[:pattern]}'") unless match
  match[1]
end