fastlane-plugin-versioning 0.3.4 → 0.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +140 -8
- data/lib/fastlane/plugin/versioning/actions/ci_build_number.rb +11 -3
- data/lib/fastlane/plugin/versioning/actions/get_app_store_version_number.rb +6 -6
- data/lib/fastlane/plugin/versioning/actions/get_build_number_from_plist.rb +19 -7
- data/lib/fastlane/plugin/versioning/actions/get_build_number_from_xcodeproj.rb +127 -0
- data/lib/fastlane/plugin/versioning/actions/get_info_plist_path.rb +45 -50
- data/lib/fastlane/plugin/versioning/actions/get_version_number_from_git_branch.rb +1 -1
- data/lib/fastlane/plugin/versioning/actions/get_version_number_from_plist.rb +20 -8
- data/lib/fastlane/plugin/versioning/actions/get_version_number_from_xcodeproj.rb +111 -0
- data/lib/fastlane/plugin/versioning/actions/increment_build_number_in_plist.rb +36 -10
- data/lib/fastlane/plugin/versioning/actions/increment_build_number_in_xcodeproj.rb +127 -0
- data/lib/fastlane/plugin/versioning/actions/increment_version_number_in_plist.rb +39 -14
- data/lib/fastlane/plugin/versioning/actions/increment_version_number_in_xcodeproj.rb +178 -0
- data/lib/fastlane/plugin/versioning/version.rb +1 -1
- metadata +11 -5
@@ -15,32 +15,52 @@ module Fastlane
|
|
15
15
|
version_array = current_version.split(".").map(&:to_i)
|
16
16
|
case params[:bump_type]
|
17
17
|
when "patch"
|
18
|
-
version_array[2] = (version_array[2]
|
18
|
+
version_array[2] = (version_array[2] || 0) + 1
|
19
19
|
when "minor"
|
20
|
-
version_array[1] = (version_array[1]
|
20
|
+
version_array[1] = (version_array[1] || 0) + 1
|
21
21
|
version_array[2] = version_array[2] = 0
|
22
22
|
when "major"
|
23
|
-
version_array[0] = (version_array[0]
|
23
|
+
version_array[0] = (version_array[0] || 0) + 1
|
24
24
|
version_array[1] = version_array[1] = 0
|
25
25
|
version_array[1] = version_array[2] = 0
|
26
26
|
end
|
27
27
|
|
28
28
|
if params[:omit_zero_patch_version] && version_array[2] == 0
|
29
|
-
version_array.pop
|
29
|
+
version_array.pop
|
30
30
|
end
|
31
31
|
|
32
32
|
next_version_number = version_array.join(".")
|
33
33
|
end
|
34
34
|
|
35
35
|
if Helper.test?
|
36
|
-
plist = "/tmp/fastlane/tests/fastlane/Info.plist"
|
36
|
+
plist = "/tmp/fastlane/tests/fastlane/plist/Info.plist"
|
37
37
|
else
|
38
38
|
plist = GetInfoPlistPathAction.run(params)
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
if current_version =~ /\$\(([\w\-]+)\)/
|
42
|
+
UI.important "detected that version is a build setting."
|
43
|
+
if params[:plist_build_setting_support]
|
44
|
+
UI.important "will continue and update the xcodeproj MARKETING_VERSION instead."
|
45
|
+
IncrementVersionNumberInXcodeprojAction.run(params)
|
46
|
+
else
|
47
|
+
UI.important "will continue and update the info plist key. this will replace the existing value."
|
48
|
+
SetInfoPlistValueAction.run(path: plist, key: 'CFBundleShortVersionString', value: next_version_number)
|
49
|
+
end
|
50
|
+
else
|
51
|
+
if params[:plist_build_setting_support]
|
52
|
+
UI.important "will update the xcodeproj MARKETING_VERSION."
|
53
|
+
IncrementVersionNumberInXcodeprojAction.run(params)
|
54
|
+
UI.important "will also update info plist key to be a build setting"
|
55
|
+
SetInfoPlistValueAction.run(path: plist, key: 'CFBundleShortVersionString', value: "$(MARKETING_VERSION)")
|
56
|
+
else
|
57
|
+
UI.important "will update the info plist key. this will replace the existing value."
|
58
|
+
SetInfoPlistValueAction.run(path: plist, key: 'CFBundleShortVersionString', value: next_version_number)
|
59
|
+
end
|
60
|
+
end
|
42
61
|
|
43
62
|
Actions.lane_context[SharedValues::VERSION_NUMBER] = next_version_number
|
63
|
+
next_version_number
|
44
64
|
end
|
45
65
|
|
46
66
|
def self.description
|
@@ -49,7 +69,8 @@ module Fastlane
|
|
49
69
|
|
50
70
|
def self.details
|
51
71
|
[
|
52
|
-
"This action will increment the version number directly in Info.plist. "
|
72
|
+
"This action will increment the version number directly in Info.plist. ",
|
73
|
+
"unless plist_build_setting_support: true is passed in as parameters"
|
53
74
|
].join("\n")
|
54
75
|
end
|
55
76
|
|
@@ -76,7 +97,7 @@ module Fastlane
|
|
76
97
|
env_name: "FL_APPSTORE_VERSION_NUMBER_BUNDLE_ID",
|
77
98
|
description: "Bundle ID of the application",
|
78
99
|
optional: true,
|
79
|
-
conflicting_options: [
|
100
|
+
conflicting_options: %i[xcodeproj target build_configuration_name scheme],
|
80
101
|
is_string: true),
|
81
102
|
FastlaneCore::ConfigItem.new(key: :xcodeproj,
|
82
103
|
env_name: "FL_VERSION_NUMBER_PROJECT",
|
@@ -90,12 +111,12 @@ module Fastlane
|
|
90
111
|
FastlaneCore::ConfigItem.new(key: :target,
|
91
112
|
env_name: "FL_VERSION_NUMBER_TARGET",
|
92
113
|
optional: true,
|
93
|
-
conflicting_options: [
|
114
|
+
conflicting_options: %i[bundle_id scheme],
|
94
115
|
description: "Specify a specific target if you have multiple per project, optional"),
|
95
116
|
FastlaneCore::ConfigItem.new(key: :scheme,
|
96
117
|
env_name: "FL_VERSION_NUMBER_SCHEME",
|
97
118
|
optional: true,
|
98
|
-
conflicting_options: [
|
119
|
+
conflicting_options: %i[bundle_id target],
|
99
120
|
description: "Specify a specific scheme if you have multiple per project, optional"),
|
100
121
|
FastlaneCore::ConfigItem.new(key: :build_configuration_name,
|
101
122
|
optional: true,
|
@@ -107,7 +128,11 @@ module Fastlane
|
|
107
128
|
verify_block: proc do |value|
|
108
129
|
UI.user_error!("Available values are 'plist' and 'appstore'") unless ['plist', 'appstore'].include? value
|
109
130
|
end,
|
110
|
-
description: "Source version to increment. Available options: plist, appstore")
|
131
|
+
description: "Source version to increment. Available options: plist, appstore"),
|
132
|
+
FastlaneCore::ConfigItem.new(key: :plist_build_setting_support,
|
133
|
+
description: "support automatic resolution of build setting from xcodeproj if not a literal value in the plist",
|
134
|
+
is_string: false,
|
135
|
+
default_value: false)
|
111
136
|
]
|
112
137
|
end
|
113
138
|
|
@@ -117,12 +142,12 @@ module Fastlane
|
|
117
142
|
]
|
118
143
|
end
|
119
144
|
|
120
|
-
def self.
|
121
|
-
"SiarheiFedartsou"
|
145
|
+
def self.authors
|
146
|
+
["SiarheiFedartsou", "jdouglas-nz"]
|
122
147
|
end
|
123
148
|
|
124
149
|
def self.is_supported?(platform)
|
125
|
-
[
|
150
|
+
%i[ios mac].include? platform
|
126
151
|
end
|
127
152
|
end
|
128
153
|
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
module Fastlane
|
2
|
+
module Actions
|
3
|
+
class IncrementVersionNumberInXcodeprojAction < Action
|
4
|
+
def self.run(params)
|
5
|
+
if params[:version_number]
|
6
|
+
next_version_number = params[:version_number]
|
7
|
+
else
|
8
|
+
case params[:version_source]
|
9
|
+
when "xcodeproj"
|
10
|
+
current_version = GetVersionNumberFromXcodeprojAction.run(params)
|
11
|
+
when "appstore"
|
12
|
+
current_version = GetAppStoreVersionNumberAction.run(params)
|
13
|
+
end
|
14
|
+
|
15
|
+
version_array = current_version.split(".").map(&:to_i)
|
16
|
+
case params[:bump_type]
|
17
|
+
when "patch"
|
18
|
+
version_array[2] = (version_array[2] || 0) + 1
|
19
|
+
when "minor"
|
20
|
+
version_array[1] = (version_array[1] || 0) + 1
|
21
|
+
version_array[2] = version_array[2] = 0
|
22
|
+
when "major"
|
23
|
+
version_array[0] = (version_array[0] || 0) + 1
|
24
|
+
version_array[1] = version_array[1] = 0
|
25
|
+
version_array[1] = version_array[2] = 0
|
26
|
+
end
|
27
|
+
|
28
|
+
if params[:omit_zero_patch_version] && version_array[2] == 0
|
29
|
+
version_array.pop
|
30
|
+
end
|
31
|
+
|
32
|
+
next_version_number = version_array.join(".")
|
33
|
+
end
|
34
|
+
|
35
|
+
if Helper.test?
|
36
|
+
params[:xcodeproj] = "/tmp/fastlane/tests/fastlane/xcodeproj/versioning_fixture_project.xcodeproj"
|
37
|
+
else
|
38
|
+
params[:xcodeproj] = Dir["*.xcodeproj"][0] unless params[:xcodeproj]
|
39
|
+
end
|
40
|
+
|
41
|
+
if params[:target]
|
42
|
+
set_version_number_using_target(params, next_version_number)
|
43
|
+
elsif params[:build_configuration_name] && params[:scheme]
|
44
|
+
set_version_number_using_scheme(params, next_version_number)
|
45
|
+
else
|
46
|
+
set_all_xcodeproj_version_numbers(params, next_version_number)
|
47
|
+
end
|
48
|
+
|
49
|
+
Actions.lane_context[SharedValues::VERSION_NUMBER] = next_version_number
|
50
|
+
next_version_number
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.set_all_xcodeproj_version_numbers(params, next_version_number)
|
54
|
+
project = Xcodeproj::Project.open(params[:xcodeproj])
|
55
|
+
configs = project.objects.select { |obj| select_build_configuration_predicate(nil, obj) }
|
56
|
+
configs.each do |config|
|
57
|
+
config.build_settings["MARKETING_VERSION"] = next_version_number
|
58
|
+
end
|
59
|
+
project.save
|
60
|
+
end
|
61
|
+
|
62
|
+
private_class_method
|
63
|
+
def self.select_build_configuration_predicate(name, configuration)
|
64
|
+
is_build_valid_configuration = configuration.isa == "XCBuildConfiguration" && !configuration.build_settings["PRODUCT_BUNDLE_IDENTIFIER"].nil?
|
65
|
+
is_build_valid_configuration &&= configuration.name == name unless name.nil?
|
66
|
+
return is_build_valid_configuration
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.set_version_number_using_target(params, next_version_number)
|
70
|
+
project = Xcodeproj::Project.open(params[:xcodeproj])
|
71
|
+
if params[:target]
|
72
|
+
target = project.targets.detect { |t| t.name == params[:target] }
|
73
|
+
else
|
74
|
+
# firstly we are trying to find modern application target
|
75
|
+
target = project.targets.detect do |t|
|
76
|
+
t.kind_of?(Xcodeproj::Project::Object::PBXNativeTarget) &&
|
77
|
+
t.product_type == 'com.apple.product-type.application'
|
78
|
+
end
|
79
|
+
target = project.targets[0] if target.nil?
|
80
|
+
end
|
81
|
+
|
82
|
+
target.build_configurations.each do |config|
|
83
|
+
UI.message "updating #{config.name} to version #{next_version_number}"
|
84
|
+
config.build_settings["MARKETING_VERSION"] = next_version_number
|
85
|
+
end unless target.nil?
|
86
|
+
|
87
|
+
project.save
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.set_version_number_using_scheme(params, next_version_number)
|
91
|
+
project = Xcodeproj::Project.open(params[:xcodeproj])
|
92
|
+
configs = project.objects.select { |obj| select_build_configuration_predicate(params[:build_configuration_name], obj) }
|
93
|
+
configs.each do |config|
|
94
|
+
config.build_settings["MARKETING_VERSION"] = next_version_number
|
95
|
+
end
|
96
|
+
project.save
|
97
|
+
end
|
98
|
+
|
99
|
+
#####################################################
|
100
|
+
# @!group Documentation
|
101
|
+
#####################################################
|
102
|
+
|
103
|
+
def self.description
|
104
|
+
"Increment build number in xcodeproj"
|
105
|
+
end
|
106
|
+
|
107
|
+
def self.available_options
|
108
|
+
[
|
109
|
+
FastlaneCore::ConfigItem.new(key: :bump_type,
|
110
|
+
env_name: "FL_VERSION_NUMBER_BUMP_TYPE",
|
111
|
+
description: "The type of this version bump. Available: patch, minor, major",
|
112
|
+
default_value: "patch",
|
113
|
+
verify_block: proc do |value|
|
114
|
+
UI.user_error!("Available values are 'patch', 'minor' and 'major'") unless ['patch', 'minor', 'major'].include? value
|
115
|
+
end),
|
116
|
+
FastlaneCore::ConfigItem.new(key: :version_number,
|
117
|
+
env_name: "FL_VERSION_NUMBER_VERSION_NUMBER",
|
118
|
+
description: "Change to a specific version. This will replace the bump type value",
|
119
|
+
optional: true),
|
120
|
+
FastlaneCore::ConfigItem.new(key: :omit_zero_patch_version,
|
121
|
+
env_name: "FL_VERSION_NUMBER_OMIT_ZERO_PATCH_VERSION",
|
122
|
+
description: "If true omits zero in patch version(so 42.10.0 will become 42.10 and 42.10.1 will remain 42.10.1)",
|
123
|
+
default_value: false,
|
124
|
+
optional: true,
|
125
|
+
is_string: false),
|
126
|
+
FastlaneCore::ConfigItem.new(key: :bundle_id,
|
127
|
+
env_name: "FL_APPSTORE_VERSION_NUMBER_BUNDLE_ID",
|
128
|
+
description: "Bundle ID of the application",
|
129
|
+
optional: true,
|
130
|
+
conflicting_options: %i[xcodeproj target build_configuration_name scheme],
|
131
|
+
is_string: true),
|
132
|
+
FastlaneCore::ConfigItem.new(key: :xcodeproj,
|
133
|
+
env_name: "FL_VERSION_NUMBER_PROJECT",
|
134
|
+
description: "optional, you must specify the path to your main Xcode project if it is not in the project root directory",
|
135
|
+
optional: true,
|
136
|
+
conflicting_options: [:bundle_id],
|
137
|
+
verify_block: proc do |value|
|
138
|
+
UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with? ".xcworkspace"
|
139
|
+
UI.user_error!("Could not find Xcode project at path '#{File.expand_path(value)}'") if !File.exist?(value) and !Helper.is_test?
|
140
|
+
end),
|
141
|
+
FastlaneCore::ConfigItem.new(key: :target,
|
142
|
+
env_name: "FL_VERSION_NUMBER_TARGET",
|
143
|
+
optional: true,
|
144
|
+
conflicting_options: %i[bundle_id scheme],
|
145
|
+
description: "Specify a specific target if you have multiple per project, optional"),
|
146
|
+
FastlaneCore::ConfigItem.new(key: :scheme,
|
147
|
+
env_name: "FL_VERSION_NUMBER_SCHEME",
|
148
|
+
optional: true,
|
149
|
+
conflicting_options: %i[bundle_id target],
|
150
|
+
description: "Specify a specific scheme if you have multiple per project, optional"),
|
151
|
+
FastlaneCore::ConfigItem.new(key: :build_configuration_name,
|
152
|
+
optional: true,
|
153
|
+
conflicting_options: [:bundle_id],
|
154
|
+
description: "Specify a specific build configuration if you have different build settings for each configuration"),
|
155
|
+
FastlaneCore::ConfigItem.new(key: :version_source,
|
156
|
+
optional: true,
|
157
|
+
default_value: 'xcodeproj',
|
158
|
+
verify_block: proc do |value|
|
159
|
+
UI.user_error!("Available values are 'xcodeproj' and 'appstore'") unless ['xcodeproj', 'appstore'].include? value
|
160
|
+
end,
|
161
|
+
description: "Source version to increment. Available options: xcodeproj, appstore"),
|
162
|
+
FastlaneCore::ConfigItem.new(key: :plist_build_setting_support,
|
163
|
+
description: "support automatic resolution of build setting from xcodeproj if not a literal value in the plist",
|
164
|
+
is_string: false,
|
165
|
+
default_value: false)
|
166
|
+
]
|
167
|
+
end
|
168
|
+
|
169
|
+
def self.authors
|
170
|
+
["jdouglas-nz", "neilb01"]
|
171
|
+
end
|
172
|
+
|
173
|
+
def self.is_supported?(platform)
|
174
|
+
%i[ios mac android].include? platform
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fastlane-plugin-versioning
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Siarhei Fiedartsou
|
8
|
+
- John Douglas
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2021-05-02 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: pry
|
@@ -67,7 +68,9 @@ dependencies:
|
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: 1.93.1
|
69
70
|
description:
|
70
|
-
email:
|
71
|
+
email:
|
72
|
+
- siarhei.fedartsou@gmail.com
|
73
|
+
- john.douglas.nz@gmail.com
|
71
74
|
executables: []
|
72
75
|
extensions: []
|
73
76
|
extra_rdoc_files: []
|
@@ -78,11 +81,15 @@ files:
|
|
78
81
|
- lib/fastlane/plugin/versioning/actions/ci_build_number.rb
|
79
82
|
- lib/fastlane/plugin/versioning/actions/get_app_store_version_number.rb
|
80
83
|
- lib/fastlane/plugin/versioning/actions/get_build_number_from_plist.rb
|
84
|
+
- lib/fastlane/plugin/versioning/actions/get_build_number_from_xcodeproj.rb
|
81
85
|
- lib/fastlane/plugin/versioning/actions/get_info_plist_path.rb
|
82
86
|
- lib/fastlane/plugin/versioning/actions/get_version_number_from_git_branch.rb
|
83
87
|
- lib/fastlane/plugin/versioning/actions/get_version_number_from_plist.rb
|
88
|
+
- lib/fastlane/plugin/versioning/actions/get_version_number_from_xcodeproj.rb
|
84
89
|
- lib/fastlane/plugin/versioning/actions/increment_build_number_in_plist.rb
|
90
|
+
- lib/fastlane/plugin/versioning/actions/increment_build_number_in_xcodeproj.rb
|
85
91
|
- lib/fastlane/plugin/versioning/actions/increment_version_number_in_plist.rb
|
92
|
+
- lib/fastlane/plugin/versioning/actions/increment_version_number_in_xcodeproj.rb
|
86
93
|
- lib/fastlane/plugin/versioning/version.rb
|
87
94
|
homepage: https://github.com/SiarheiFedartsou/fastlane-plugin-versioning
|
88
95
|
licenses:
|
@@ -103,8 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
110
|
- !ruby/object:Gem::Version
|
104
111
|
version: '0'
|
105
112
|
requirements: []
|
106
|
-
|
107
|
-
rubygems_version: 2.6.12
|
113
|
+
rubygems_version: 3.0.6
|
108
114
|
signing_key:
|
109
115
|
specification_version: 4
|
110
116
|
summary: Allows to set/get app version and build number directly to/from Info.plist
|