Class: Fastlane::Actions::GetVersionNumberAction
Constant Summary
Fastlane::Action::AVAILABLE_CATEGORIES
Class Method Summary
collapse
action_name, author, lane_context, method_missing, other_action, return_value, sample_return_value, sh, step_text
Class Method Details
.authors ⇒ Object
137
138
139
|
# File 'lib/fastlane/actions/get_version_number.rb', line 137
def self.authors
["Liquidsoul"]
end
|
.available_options ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/fastlane/actions/get_version_number.rb', line 106
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: :scheme,
env_name: "FL_VERSION_NUMBER_SCHEME",
description: "Specify a specific scheme if you have multiple per project, optional.
This parameter is deprecated and will be removed in a future release.
Please use the 'target' parameter instead. The behavior of this parameter
is currently undefined if your scheme name doesn't match your target name",
optional: true,
deprecated: true),
FastlaneCore::ConfigItem.new(key: :target,
env_name: "FL_VERSION_NUMBER_TARGET",
description: "Specify a specific target if you have multiple per project, optional",
optional: true)
]
end
|
.category ⇒ Object
151
152
153
|
# File 'lib/fastlane/actions/get_version_number.rb', line 151
def self.category
:project
end
|
.description ⇒ Object
94
95
96
|
# File 'lib/fastlane/actions/get_version_number.rb', line 94
def self.description
"Get the version number of your project"
end
|
.details ⇒ Object
98
99
100
101
102
103
104
|
# File 'lib/fastlane/actions/get_version_number.rb', line 98
def self.details
[
"This action will return the current version number set on your project.",
"You first have to set up your Xcode project, if you haven't done it already:",
"https://developer.apple.com/library/ios/qa/qa1827/_index.html"
].join(' ')
end
|
.example_code ⇒ Object
145
146
147
148
149
|
# File 'lib/fastlane/actions/get_version_number.rb', line 145
def self.example_code
[
'version = get_version_number(xcodeproj: "Project.xcodeproj")'
]
end
|
.is_supported?(platform) ⇒ Boolean
141
142
143
|
# File 'lib/fastlane/actions/get_version_number.rb', line 141
def self.is_supported?(platform)
[:ios, :mac].include? platform
end
|
.output ⇒ Object
131
132
133
134
135
|
# File 'lib/fastlane/actions/get_version_number.rb', line 131
def self.output
[
['VERSION_NUMBER', 'The version number']
]
end
|
.run(params) ⇒ Object
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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/fastlane/actions/get_version_number.rb', line 6
def self.run(params)
folder = params[:xcodeproj] ? File.join(params[:xcodeproj], '..') : '.'
command_prefix = [
'cd',
File.expand_path(folder).shellescape,
'&&'
].join(' ')
command = [
command_prefix,
'agvtool',
'what-marketing-version',
'-terse'
].join(' ')
line = ""
scheme = params[:scheme] || ""
target = params[:target] || ""
results = []
if Helper.test?
results = [
'$(date +%s)n /usr/libexec/Plistbuddy -c "Set CFBundleVersion $buildnum" "${plist}"n',
'"SampleProject.xcodeproj/../TargetA/TargetA-Info.plist"=4.3.2',
'"SampleProject.xcodeproj/../TargetATests/Info.plist"=4.3.2',
'"SampleProject.xcodeproj/../TargetB/TargetB-Info.plist"=5.4.3',
'"SampleProject.xcodeproj/../TargetBTests/Info.plist"=5.4.3',
'"SampleProject.xcodeproj/../SampleProject/supporting_files/TargetC_internal-Info.plist"=7.5.2',
'"SampleProject.xcodeproj/../SampleProject/supporting_files/TargetC_production-Info.plist"=6.4.9',
'"SampleProject.xcodeproj/../SampleProject_tests/Info.plist"=1.0'
]
else
results = (Actions.sh command).split("\n")
end
if target.empty? && scheme.empty?
project_string = ".xcodeproj"
results.any? do |result|
if result.include? project_string
line = result
break
end
end
else
scheme_string = "/#{scheme}"
target_string = "/#{target}/"
plist_target_string = "/#{target}-"
results.any? do |result|
if !target.empty?
if result.include? target_string
line = result
break
elsif result.include? plist_target_string
line = result
break
end
else
if result.include? scheme_string
line = result
break
end
end
end
end
version_number = line.partition('=').last
return version_number if Helper.is_test?
Actions.lane_context[SharedValues::VERSION_NUMBER] = version_number
rescue => ex
UI.error('Make sure to follow the steps to setup your Xcode project: https://developer.apple.com/library/ios/qa/qa1827/_index.html')
raise ex
end
|