Class: Fastlane::Actions::GetBuildNumberFromPlistAction

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

Documentation collapse

Class Method Summary collapse

Class Method Details

.authorsObject



79
80
81
# File 'lib/fastlane/plugin/versioning/actions/get_build_number_from_plist.rb', line 79

def self.authors
  ["SiarheiFedartsou"]
end

.available_optionsObject



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fastlane/plugin/versioning/actions/get_build_number_from_plist.rb', line 39

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :xcodeproj,
                       env_name: "FL_BUILD_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_BUILD_NUMBER_TARGET",
                       optional: true,
                       conflicting_options: [:scheme],
                       description: "Specify a specific target if you have multiple per project, optional"),
    FastlaneCore::ConfigItem.new(key: :scheme,
                       env_name: "FL_BUILD_NUMBER_SCHEME",
                       optional: true,
                       conflicting_options: [:target],
                       description: "Specify a specific scheme 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"),
    FastlaneCore::ConfigItem.new(key: :plist_build_setting_support,
                        description: "support automatic resolution of build setting from xcodeproj if not a literal value in the plist",
                        is_string: false,
                        default_value: false),
    FastlaneCore::ConfigItem.new(key: :skip_package_dependencies_resolution,
                         description: "Skips resolution of Swift Package Manager dependencies",
                         type: Boolean,
                         default_value: false)
  ]
end

.descriptionObject



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

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

.detailsObject



32
33
34
35
36
37
# File 'lib/fastlane/plugin/versioning/actions/get_build_number_from_plist.rb', line 32

def self.details
  [
    "This action will return the current build number set on your project's Info.plist.",
    "note that you can pass plist_build_setting_support: true, in which case it will return from your xcodeproj."
  ].join(' ')
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/fastlane/plugin/versioning/actions/get_build_number_from_plist.rb', line 83

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

.outputObject



73
74
75
76
77
# File 'lib/fastlane/plugin/versioning/actions/get_build_number_from_plist.rb', line 73

def self.output
  [
    ['BUILD_NUMBER', 'The build number']
  ]
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fastlane/plugin/versioning/actions/get_build_number_from_plist.rb', line 4

def self.run(params)
  if Helper.test?
    plist = "/tmp/fastlane/tests/fastlane/plist/Info.plist"
  else
    plist = GetInfoPlistPathAction.run(params)
  end

  if params[:plist_build_setting_support]
    UI.important "build number will originate from xcodeproj"
    build_number = GetBuildNumberFromXcodeprojAction.run(params)
  else
    UI.important "build number will originate from plist."
    build_number = GetInfoPlistValueAction.run(path: plist, key: 'CFBundleVersion')
  end

  # Store the number in the shared hash
  Actions.lane_context[SharedValues::BUILD_NUMBER] = build_number
  build_number
end