class Fastlane::Actions::GetVersionNumberFromGitBranchAction

Public Class Methods

authors() click to toggle source
# File lib/fastlane/plugin/versioning/actions/get_version_number_from_git_branch.rb, line 37
def self.authors
  ["SiarheiFedartsou"]
end
available_options() click to toggle source
# 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
description() click to toggle source

@!group Documentation

# 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) click to toggle source
# 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) click to toggle source
# 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