Class: Fastlane::Actions::GetVersionNumberFromPlistAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authors ⇒ Object



59
60
61
# File 'lib/fastlane/plugin/versioning/actions/get_version_number_from_plist.rb', line 59

def self.authors
  ["SiarheiFedartsou"]
end

.available_options ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/fastlane/plugin/versioning/actions/get_version_number_from_plist.rb', line 32

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :xcodeproj,
                       env_name: "FL_VERSION_NUMBER_PROJECT",
                       description: "optional, you must specify the path to your main Xcode project if it is not in the project root directory",
                       optional: true,
                       verify_block: proc do |value|
                         UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with? ".xcworkspace"
                         UI.user_error!("Could not find Xcode project at path '#{File.expand_path(value)}'") if !File.exist?(value) and !Helper.is_test?
                       end),
    FastlaneCore::ConfigItem.new(key: :target,
                       env_name: "FL_VERSION_NUMBER_TARGET",
                       optional: true,
                       description: "Specify a specific target if you have multiple per project, optional"),
    FastlaneCore::ConfigItem.new(key: :build_configuration_name,
                       optional: true,
                       description: "Specify a specific build configuration if you have different Info.plist build settings for each configuration")

  ]
end

.description ⇒ Object



22
23
24
# File 'lib/fastlane/plugin/versioning/actions/get_version_number_from_plist.rb', line 22

def self.description
  "Get the version number of your project"
end

.details ⇒ Object



26
27
28
29
30
# File 'lib/fastlane/plugin/versioning/actions/get_version_number_from_plist.rb', line 26

def self.details
  [
    "This action will return the current version number set on your project's Info.plist."
  ].join(' ')
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/fastlane/plugin/versioning/actions/get_version_number_from_plist.rb', line 63

def self.is_supported?(platform)
  [:ios, :mac].include? platform
end

.output ⇒ Object



53
54
55
56
57
# File 'lib/fastlane/plugin/versioning/actions/get_version_number_from_plist.rb', line 53

def self.output
  [
    ['VERSION_NUMBER', 'The version number']
  ]
end

.run(params) ⇒ Object



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

def self.run(params)
  if Helper.test?
    plist = "/tmp/fastlane/tests/fastlane/Info.plist"
  else
    plist = GetInfoPlistPathAction.run(xcodeproj: params[:xcodeproj],
   target: params[:target],
   build_configuration_name: params[:build_configuration_name])
  end

  version_number = GetInfoPlistValueAction.run(path: plist, key: 'CFBundleShortVersionString')
  # Store the number in the shared hash
  Actions.lane_context[SharedValues::VERSION_NUMBER] = version_number
end