fastlane-plugin-wpmreleasetoolkit 11.0.3 → 12.0.0
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 +4 -4
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_xml_release_notes.rb +0 -2
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +1 -9
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/close_milestone_action.rb +0 -2
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/{create_release_action.rb → create_github_release_action.rb} +1 -3
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb +0 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb +218 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb +63 -0
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb +0 -3
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +2 -373
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb +27 -22
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +26 -1
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb +0 -270
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_short_metadata_block.rb +2 -2
- data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +1 -1
- metadata +9 -58
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +0 -137
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +0 -108
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +0 -90
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +0 -82
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +0 -91
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +0 -109
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +0 -108
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +0 -86
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +0 -89
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +0 -62
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +0 -62
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +0 -62
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb +0 -78
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +0 -70
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb +0 -98
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_prechecks.rb +0 -74
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb +0 -67
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb +0 -83
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb +0 -87
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_codefreeze_prechecks.rb +0 -76
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_completecodefreeze_prechecks.rb +0 -65
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_current_branch_is_hotfix.rb +0 -40
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_finalize_prechecks.rb +0 -66
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb +0 -54
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_number.rb +0 -54
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_version.rb +0 -60
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_hotfix_prechecks.rb +0 -78
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb +0 -44
- data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb +0 -46
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb +0 -28
- data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb +0 -28
@@ -19,48 +19,11 @@ module Fastlane
|
|
19
19
|
# The suffix used in the versionName for RC (beta) versions
|
20
20
|
RC_SUFFIX = '-rc'.freeze
|
21
21
|
|
22
|
-
# Returns the public-facing version string.
|
23
|
-
#
|
24
|
-
# @example
|
25
|
-
# "1.2" # Assuming build.gradle contains versionName "1.2"
|
26
|
-
# "1.2" # Assuming build.gradle contains versionName "1.2.0"
|
27
|
-
# "1.2.3" # Assuming build.gradle contains versionName "1.2.3"
|
28
|
-
#
|
29
|
-
# @return [String] The public-facing version number, extracted from the `versionName` of the `build.gradle` file.
|
30
|
-
# - If this version is a hotfix (more than 2 parts and 3rd part is non-zero), returns the "X.Y.Z" formatted string
|
31
|
-
# - Otherwise (not a hotfix / 3rd part of version is 0), returns "X.Y" formatted version number
|
32
|
-
#
|
33
|
-
def self.get_public_version(build_gradle_path:, version_properties_path:)
|
34
|
-
version = get_release_version(
|
35
|
-
build_gradle_path: build_gradle_path,
|
36
|
-
version_properties_path: version_properties_path
|
37
|
-
)
|
38
|
-
vp = get_version_parts(version[VERSION_NAME])
|
39
|
-
return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}" unless is_hotfix?(version)
|
40
|
-
|
41
|
-
"#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}"
|
42
|
-
end
|
43
|
-
|
44
22
|
# Extract the version name and code from the release version of the app from `version.properties file`
|
45
23
|
#
|
46
24
|
# @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively
|
47
25
|
#
|
48
|
-
def self.get_release_version(
|
49
|
-
return get_version_from_properties(version_properties_path: version_properties_path) if File.exist?(version_properties_path)
|
50
|
-
|
51
|
-
section = 'defaultConfig'
|
52
|
-
name = get_version_name_from_gradle_file(build_gradle_path, section)
|
53
|
-
code = get_version_build_from_gradle_file(build_gradle_path, section)
|
54
|
-
{ VERSION_NAME => name, VERSION_CODE => code }
|
55
|
-
end
|
56
|
-
|
57
|
-
# Extract the version name and code from the `version.properties` file in the project root
|
58
|
-
#
|
59
|
-
# @param [Boolean] is_alpha true if the alpha version should be returned, false otherwise
|
60
|
-
#
|
61
|
-
# @return [Hash] A hash with 2 keys "name" and "code" containing the extracted version name and code, respectively
|
62
|
-
#
|
63
|
-
def self.get_version_from_properties(version_properties_path:, is_alpha: false)
|
26
|
+
def self.get_release_version(version_properties_path:, is_alpha: false)
|
64
27
|
return nil unless File.exist?(version_properties_path)
|
65
28
|
|
66
29
|
version_name_key = is_alpha ? 'alpha.versionName' : 'versionName'
|
@@ -73,107 +36,6 @@ module Fastlane
|
|
73
36
|
name.nil? || code.nil? ? nil : { VERSION_NAME => name, VERSION_CODE => code.to_i }
|
74
37
|
end
|
75
38
|
|
76
|
-
# Extract the version name and code from the `version.properties` file in the project root
|
77
|
-
#
|
78
|
-
# @return [Hash] A hash with 2 keys `"name"` and `"code"` containing the extracted version name and code, respectively
|
79
|
-
#
|
80
|
-
def self.get_alpha_version(build_gradle_path:, version_properties_path:)
|
81
|
-
return get_version_from_properties(version_properties_path: version_properties_path, is_alpha: true) if File.exist?(version_properties_path)
|
82
|
-
|
83
|
-
section = 'defaultConfig'
|
84
|
-
name = get_version_name_from_gradle_file(build_gradle_path, section)
|
85
|
-
code = get_version_build_from_gradle_file(build_gradle_path, section)
|
86
|
-
{ VERSION_NAME => name, VERSION_CODE => code }
|
87
|
-
end
|
88
|
-
|
89
|
-
# Determines if a version name corresponds to an alpha version (starts with `"alpha-"`` prefix)
|
90
|
-
#
|
91
|
-
# @param [String] version The version name to check
|
92
|
-
#
|
93
|
-
# @return [Bool] true if the version name starts with the `ALPHA_PREFIX`, false otherwise.
|
94
|
-
#
|
95
|
-
# @private
|
96
|
-
#
|
97
|
-
def self.is_alpha_version?(version)
|
98
|
-
version[VERSION_NAME].start_with?(ALPHA_PREFIX)
|
99
|
-
end
|
100
|
-
|
101
|
-
# Check if this versionName corresponds to a beta, i.e. contains some `-rc` suffix
|
102
|
-
#
|
103
|
-
# @param [String] version The versionName string to check for
|
104
|
-
#
|
105
|
-
# @return [Bool] True if the version string contains `-rc`, indicating it is a beta version.
|
106
|
-
#
|
107
|
-
def self.is_beta_version?(version)
|
108
|
-
version[VERSION_NAME].include?(RC_SUFFIX)
|
109
|
-
end
|
110
|
-
|
111
|
-
# Returns the version name and code to use for the final release.
|
112
|
-
#
|
113
|
-
# - The final version name corresponds to the beta's versionName, without the `-rc` suffix
|
114
|
-
# - The final version code corresponds to the versionCode for the alpha (or for the beta if alpha_version is nil) incremented by one.
|
115
|
-
#
|
116
|
-
# @param [Hash] beta_version The version hash for the beta, containing values for keys "name" and "code"
|
117
|
-
# @param [Hash] alpha_version The version hash for the alpha, containing values for keys "name" and "code",
|
118
|
-
# or `nil` if no alpha version to consider.
|
119
|
-
#
|
120
|
-
# @return [Hash] A version hash with keys "name" and "code", containing the version name and code to use for final release.
|
121
|
-
#
|
122
|
-
def self.calc_final_release_version(beta_version, alpha_version)
|
123
|
-
version_name = beta_version[VERSION_NAME].split('-')[0]
|
124
|
-
version_code = alpha_version.nil? ? beta_version[VERSION_CODE] + 1 : alpha_version[VERSION_CODE] + 1
|
125
|
-
|
126
|
-
{ VERSION_NAME => version_name, VERSION_CODE => version_code }
|
127
|
-
end
|
128
|
-
|
129
|
-
# Returns the version name and code to use for the next alpha.
|
130
|
-
#
|
131
|
-
# - The next version name corresponds to the `alpha_version`'s name incremented by one (alpha-42 => alpha-43)
|
132
|
-
# - The next version code corresponds to the `version`'s code incremented by one.
|
133
|
-
#
|
134
|
-
# @param [Hash] version The version hash for the current beta or release, containing values for keys "name" and "code"
|
135
|
-
# @param [Hash] alpha_version The version hash for the current alpha (defaultConfig), containing values for keys "name" and "code"
|
136
|
-
#
|
137
|
-
# @return [Hash] A version hash with keys "name" and "code", containing the version name and code to use for final release.
|
138
|
-
#
|
139
|
-
def self.calc_next_alpha_version(version, alpha_version)
|
140
|
-
# Bump alpha name
|
141
|
-
alpha_number = alpha_version[VERSION_NAME].sub(ALPHA_PREFIX, '')
|
142
|
-
alpha_name = "#{ALPHA_PREFIX}#{alpha_number.to_i + 1}"
|
143
|
-
|
144
|
-
# Bump alpha code
|
145
|
-
alpha_code = version[VERSION_CODE] + 1
|
146
|
-
|
147
|
-
{ VERSION_NAME => alpha_name, VERSION_CODE => alpha_code }
|
148
|
-
end
|
149
|
-
|
150
|
-
# Compute the version name and code to use for the next beta (`X.Y.Z-rc-N`).
|
151
|
-
#
|
152
|
-
# - The next version name corresponds to the `version`'s name with the value after the `-rc-` suffix incremented by one,
|
153
|
-
# or with `-rc-1` added if there was no previous rc suffix (if `version` was not a beta but a release)
|
154
|
-
# - The next version code corresponds to the `alpha_version`'s (or `version`'s if `alpha_version` is nil) code, incremented by one.
|
155
|
-
#
|
156
|
-
# @example
|
157
|
-
# calc_next_beta_version({"name": "1.2.3", "code": 456}) #=> {"name": "1.2.3-rc-1", "code": 457}
|
158
|
-
# calc_next_beta_version({"name": "1.2.3-rc-2", "code": 456}) #=> {"name": "1.2.3-rc-3", "code": 457}
|
159
|
-
# calc_next_beta_version({"name": "1.2.3", "code": 456}, {"name": "alpha-1.2.3", "code": 457}) #=> {"name": "1.2.3-rc-1", "code": 458}
|
160
|
-
#
|
161
|
-
# @param [Hash] version The version hash for the current beta or release, containing values for keys "name" and "code"
|
162
|
-
# @param [Hash] alpha_version The version hash for the alpha, containing values for keys "name" and "code",
|
163
|
-
# or `nil` if no alpha version to consider.
|
164
|
-
#
|
165
|
-
# @return [Hash] A hash with keys `"name"` and `"code"` containing the next beta version name and code.
|
166
|
-
#
|
167
|
-
def self.calc_next_beta_version(version, alpha_version = nil)
|
168
|
-
# Bump version name
|
169
|
-
beta_number = is_beta_version?(version) ? version[VERSION_NAME].split('-')[2].to_i + 1 : 1
|
170
|
-
version_name = "#{version[VERSION_NAME].split('-')[0]}#{RC_SUFFIX}-#{beta_number}"
|
171
|
-
|
172
|
-
# Bump version code
|
173
|
-
version_code = alpha_version.nil? ? version[VERSION_CODE] + 1 : alpha_version[VERSION_CODE] + 1
|
174
|
-
{ VERSION_NAME => version_name, VERSION_CODE => version_code }
|
175
|
-
end
|
176
|
-
|
177
39
|
# Compute the version name to use for the next release (`"X.Y"`).
|
178
40
|
#
|
179
41
|
# @param [String] version The version name (string) to increment
|
@@ -206,57 +68,6 @@ module Fastlane
|
|
206
68
|
{ VERSION_NAME => "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}", VERSION_CODE => version[VERSION_CODE] }
|
207
69
|
end
|
208
70
|
|
209
|
-
# Compute the name of the next version to use after code freeze, by incrementing the current version name and making it a `-rc-1`
|
210
|
-
#
|
211
|
-
# @example
|
212
|
-
# calc_next_release_version({"name": "1.2", "code": 456}) #=> {"name":"1.3-rc-1", "code": 457}
|
213
|
-
# calc_next_release_version({"name": "1.2.3", "code": 456}) #=> {"name":"1.3-rc-1", "code": 457}
|
214
|
-
# calc_next_release_version({"name": "1.2", "code": 456}, {"name":"alpha-1.2", "code": 457}) #=> {"name":"1.3-rc-1", "code": 458}
|
215
|
-
#
|
216
|
-
# @param [Hash] version The current version hash, with keys `"name"` and `"code"`
|
217
|
-
# @param [Hash] alpha_version The current alpha version hash, with keys `"name"` and `"code"`, or nil if no alpha version
|
218
|
-
#
|
219
|
-
# @return [Hash] The hash containing the version name and code to use after release cut
|
220
|
-
#
|
221
|
-
def self.calc_next_release_version(version, alpha_version = nil)
|
222
|
-
nv = calc_next_release_base_version(VERSION_NAME => version[VERSION_NAME], VERSION_CODE => alpha_version.nil? ? version[VERSION_CODE] : [version[VERSION_CODE], alpha_version[VERSION_CODE]].max)
|
223
|
-
calc_next_beta_version(nv)
|
224
|
-
end
|
225
|
-
|
226
|
-
# Compute the name and code of the next hotfix version.
|
227
|
-
#
|
228
|
-
# @param [String] hotfix_version_name The next version name we want for the hotfix
|
229
|
-
# @param [String] hotfix_version_code The next version code we want for the hotfix
|
230
|
-
#
|
231
|
-
# @return [Hash] The predicted next hotfix version, as a Hash containing the keys `"name"` and `"code"`
|
232
|
-
#
|
233
|
-
def self.calc_next_hotfix_version(hotfix_version_name, hotfix_version_code)
|
234
|
-
{ VERSION_NAME => hotfix_version_name, VERSION_CODE => hotfix_version_code }
|
235
|
-
end
|
236
|
-
|
237
|
-
# Compute the name of the previous release version, by decrementing the minor version number
|
238
|
-
#
|
239
|
-
# @example
|
240
|
-
# calc_prev_release_version("1.2") => "1.1"
|
241
|
-
# calc_prev_release_version("1.2.3") => "1.1"
|
242
|
-
# calc_prev_release_version("3.0") => "2.9"
|
243
|
-
#
|
244
|
-
# @param [String] version The version string to decrement
|
245
|
-
#
|
246
|
-
# @return [String] A 2-parts version string "X.Y" corresponding to the guessed previous release version.
|
247
|
-
#
|
248
|
-
def self.calc_prev_release_version(version)
|
249
|
-
vp = get_version_parts(version)
|
250
|
-
if (vp[MINOR_NUMBER]).zero?
|
251
|
-
vp[MAJOR_NUMBER] -= 1
|
252
|
-
vp[MINOR_NUMBER] = 9
|
253
|
-
else
|
254
|
-
vp[MINOR_NUMBER] -= 1
|
255
|
-
end
|
256
|
-
|
257
|
-
"#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}"
|
258
|
-
end
|
259
|
-
|
260
71
|
# Determines if a version name corresponds to a hotfix
|
261
72
|
#
|
262
73
|
# @param [String] version The version number to test
|
@@ -264,69 +75,12 @@ module Fastlane
|
|
264
75
|
# @return [Bool] True if the version number has a non-zero 3rd component, meaning that it is a hotfix version.
|
265
76
|
#
|
266
77
|
def self.is_hotfix?(version)
|
267
|
-
return false if
|
78
|
+
return false if version[VERSION_NAME].start_with?(ALPHA_PREFIX)
|
268
79
|
|
269
80
|
vp = get_version_parts(version[VERSION_NAME])
|
270
81
|
(vp.length > 2) && (vp[HOTFIX_NUMBER] != 0)
|
271
82
|
end
|
272
83
|
|
273
|
-
# Prints the current and next release version names to stdout, then returns the next release version
|
274
|
-
#
|
275
|
-
# @return [String] The next release version name to use after bumping the currently used release version.
|
276
|
-
#
|
277
|
-
def self.bump_version_release(build_gradle_path:, version_properties_path:)
|
278
|
-
# Bump release
|
279
|
-
current_version = get_release_version(
|
280
|
-
build_gradle_path: build_gradle_path,
|
281
|
-
version_properties_path: version_properties_path
|
282
|
-
)
|
283
|
-
UI.message("Current version: #{current_version[VERSION_NAME]}")
|
284
|
-
new_version = calc_next_release_base_version(current_version)
|
285
|
-
UI.message("New version: #{new_version[VERSION_NAME]}")
|
286
|
-
verify_version(new_version[VERSION_NAME])
|
287
|
-
end
|
288
|
-
|
289
|
-
# Update the `version.properties` file with new `versionName` and `versionCode` values
|
290
|
-
#
|
291
|
-
# @param [Hash] new_version_beta The version hash for the beta, containing values for keys "name" and "code"
|
292
|
-
# @param [Hash] new_version_alpha The version hash for the alpha , containing values for keys "name" and "code"
|
293
|
-
#
|
294
|
-
def self.update_versions(new_version_beta, new_version_alpha, version_properties_path:)
|
295
|
-
if File.exist?(version_properties_path)
|
296
|
-
replacements = {
|
297
|
-
versionName: (new_version_beta || {})[VERSION_NAME],
|
298
|
-
versionCode: (new_version_beta || {})[VERSION_CODE],
|
299
|
-
'alpha.versionName': (new_version_alpha || {})[VERSION_NAME],
|
300
|
-
'alpha.versionCode': (new_version_alpha || {})[VERSION_CODE]
|
301
|
-
}
|
302
|
-
content = File.read(version_properties_path)
|
303
|
-
content.gsub!(/^(.*) ?=.*$/) do |line|
|
304
|
-
key = Regexp.last_match(1).to_sym
|
305
|
-
value = replacements[key]
|
306
|
-
value.nil? ? line : "#{key}=#{value}"
|
307
|
-
end
|
308
|
-
File.write(version_properties_path, content)
|
309
|
-
else
|
310
|
-
update_version(new_version_beta, 'defaultConfig')
|
311
|
-
update_version(new_version_alpha, 'defaultConfig') unless new_version_alpha.nil?
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
# Compute the name of the previous hotfix version.
|
316
|
-
#
|
317
|
-
# @param [String] version_name The current version name we want to decrement
|
318
|
-
#
|
319
|
-
# @return [String] The predicted previous hotfix version, in the form of "X.Y.Z", or "X.Y" if Z is 0.
|
320
|
-
# Corresponds to decrementing the 3rd component Z of the version, stripping it if it ends up being zero.
|
321
|
-
#
|
322
|
-
def self.calc_prev_hotfix_version_name(version_name)
|
323
|
-
vp = get_version_parts(version_name)
|
324
|
-
vp[HOTFIX_NUMBER] -= 1 unless (vp[HOTFIX_NUMBER]).zero?
|
325
|
-
return "#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}.#{vp[HOTFIX_NUMBER]}" unless (vp[HOTFIX_NUMBER]).zero?
|
326
|
-
|
327
|
-
"#{vp[MAJOR_NUMBER]}.#{vp[MINOR_NUMBER]}"
|
328
|
-
end
|
329
|
-
|
330
84
|
# Extract the value of a import key from build.gradle
|
331
85
|
#
|
332
86
|
# @param [String] import_key The key to look for
|
@@ -367,131 +121,6 @@ module Fastlane
|
|
367
121
|
parts.fill(0, parts.length...3) # add 0 if needed to ensure array has at least 3 components
|
368
122
|
parts
|
369
123
|
end
|
370
|
-
|
371
|
-
# Ensure that a version string is correctly formatted (that is, each of its parts is a number) and returns the 2-parts version number
|
372
|
-
#
|
373
|
-
# @param [String] version The version string to verify
|
374
|
-
#
|
375
|
-
# @return [String] The "major.minor" version string, only with the first 2 components
|
376
|
-
# @raise [UserError] If any of the parts of the version string is not a number
|
377
|
-
#
|
378
|
-
def self.verify_version(version)
|
379
|
-
v_parts = get_version_parts(version)
|
380
|
-
|
381
|
-
v_parts.each do |part|
|
382
|
-
UI.user_error!('Version value can only contains numbers.') unless is_int?(part)
|
383
|
-
end
|
384
|
-
|
385
|
-
"#{v_parts[MAJOR_NUMBER]}.#{v_parts[MINOR_NUMBER]}"
|
386
|
-
end
|
387
|
-
|
388
|
-
# Check if a string is an integer.
|
389
|
-
#
|
390
|
-
# @param [String] string The string to test
|
391
|
-
#
|
392
|
-
# @return [Bool] true if the string is representing an integer value, false if not
|
393
|
-
#
|
394
|
-
def self.is_int?(string)
|
395
|
-
true if Integer(string)
|
396
|
-
rescue StandardError
|
397
|
-
false
|
398
|
-
end
|
399
|
-
|
400
|
-
#########
|
401
|
-
# Functions to support versioning through build.gradle - can be removed once all projects adopt version.properties
|
402
|
-
########
|
403
|
-
|
404
|
-
# Extract the versionName from a build.gradle file
|
405
|
-
#
|
406
|
-
# @param [String] file_path The path to the `.gradle` file
|
407
|
-
# @param [String] section The name of the section we expect the keyword to be in, e.g. "defaultConfig" or "vanilla"
|
408
|
-
#
|
409
|
-
# @return [String] The value of the versionName attribute as found in the build.gradle file and for this section.
|
410
|
-
#
|
411
|
-
def self.get_version_name_from_gradle_file(file_path, section)
|
412
|
-
res = get_keyword_from_gradle_file(file_path, section, 'versionName')
|
413
|
-
res = res.tr('\"', '') unless res.nil?
|
414
|
-
res
|
415
|
-
end
|
416
|
-
|
417
|
-
# Extract the versionCode rom a build.gradle file
|
418
|
-
#
|
419
|
-
# @param [String] file_path The path to the `.gradle` file
|
420
|
-
# @param [String] section The name of the section we expect the keyword to be in, e.g. "defaultConfig" or "vanilla"
|
421
|
-
#
|
422
|
-
# @return [String] The value of the versionCode attribute as found in the build.gradle file and for this section.
|
423
|
-
#
|
424
|
-
def self.get_version_build_from_gradle_file(file_path, section)
|
425
|
-
res = get_keyword_from_gradle_file(file_path, section, 'versionCode')
|
426
|
-
res.to_i
|
427
|
-
end
|
428
|
-
|
429
|
-
# Extract the value for a specific keyword in a specific section of a `.gradle` file
|
430
|
-
#
|
431
|
-
# @todo: This implementation is very fragile. This should be done parsing the file in a proper way.
|
432
|
-
# Leveraging gradle itself is probably the easiest way.
|
433
|
-
#
|
434
|
-
# @param [String] file_path The path of the `.gradle` file to extract the value from
|
435
|
-
# @param [String] section The name of the section from which we want to extract this keyword from. For example `defaultConfig` or `myFlavor`
|
436
|
-
# @param [String] keyword The keyword (key name) we want the value for
|
437
|
-
#
|
438
|
-
# @return [String] Returns the value for that keyword in the section of the `.gradle` file, or nil if not found.
|
439
|
-
#
|
440
|
-
def self.get_keyword_from_gradle_file(file_path, section, keyword)
|
441
|
-
found_section = false
|
442
|
-
File.open(file_path, 'r') do |file|
|
443
|
-
file.each_line do |line|
|
444
|
-
if found_section
|
445
|
-
return line.split[1] if line.include?(keyword) && !line.include?("\"#{keyword}\"") && !line.include?("P#{keyword}")
|
446
|
-
elsif line.include?(section)
|
447
|
-
found_section = true
|
448
|
-
end
|
449
|
-
end
|
450
|
-
end
|
451
|
-
nil
|
452
|
-
end
|
453
|
-
|
454
|
-
# Update both the versionName and versionCode of the build.gradle file to the specified version.
|
455
|
-
#
|
456
|
-
# @param [Hash] version The version hash, containing values for keys "name" and "code"
|
457
|
-
# @param [String] section The name of the section to update in the build.gradle file, e.g. "defaultConfig" or "vanilla"
|
458
|
-
#
|
459
|
-
# @todo This implementation is very fragile. This should be done parsing the file in a proper way.
|
460
|
-
# Leveraging gradle itself is probably the easiest way.
|
461
|
-
#
|
462
|
-
def self.update_version(version, section, build_gradle_path:)
|
463
|
-
temp_file = Tempfile.new('fastlaneIncrementVersion')
|
464
|
-
found_section = false
|
465
|
-
version_updated = 0
|
466
|
-
File.open(build_gradle_path, 'r') do |file|
|
467
|
-
file.each_line do |line|
|
468
|
-
if found_section
|
469
|
-
if version_updated < 2
|
470
|
-
if line.include?('versionName') && !line.include?('"versionName"') && !line.include?('PversionName')
|
471
|
-
version_name = line.split[1].tr('\"', '')
|
472
|
-
line.sub!(version_name, version[VERSION_NAME].to_s)
|
473
|
-
version_updated += 1
|
474
|
-
end
|
475
|
-
|
476
|
-
if line.include? 'versionCode'
|
477
|
-
version_code = line.split[1]
|
478
|
-
line.sub!(version_code, version[VERSION_CODE].to_s)
|
479
|
-
version_updated += 1
|
480
|
-
end
|
481
|
-
end
|
482
|
-
temp_file.puts line
|
483
|
-
else
|
484
|
-
temp_file.puts line
|
485
|
-
found_section = true if line.include? section
|
486
|
-
end
|
487
|
-
end
|
488
|
-
file.close
|
489
|
-
end
|
490
|
-
temp_file.rewind
|
491
|
-
temp_file.close
|
492
|
-
FileUtils.mv(temp_file.path, build_gradle_path)
|
493
|
-
temp_file.unlink
|
494
|
-
end
|
495
124
|
end
|
496
125
|
end
|
497
126
|
end
|
@@ -67,15 +67,6 @@ module Fastlane
|
|
67
67
|
false
|
68
68
|
end
|
69
69
|
|
70
|
-
# Update every submodule in the current git repository
|
71
|
-
#
|
72
|
-
# @deprecated This method is going to be removed soon. Fastlane has a built-in `git_submodule_update` action that can be used instead.
|
73
|
-
#
|
74
|
-
def self.update_submodules
|
75
|
-
UI.deprecated("The `update_submodules` method will soon be removed from `release-toolkit`. Please use fastlane's `git_submodule_update` action instead.")
|
76
|
-
Action.sh('git', 'submodule', 'update', '--init', '--recursive')
|
77
|
-
end
|
78
|
-
|
79
70
|
# Create a new branch named `branch_name`, cutting it from branch/commit/tag `from`
|
80
71
|
#
|
81
72
|
# If the branch with that name already exists, it will instead switch to it and pull new commits.
|
@@ -179,6 +170,27 @@ module Fastlane
|
|
179
170
|
Action.sh('git', 'fetch', '--tags')
|
180
171
|
end
|
181
172
|
|
173
|
+
# Checks if two git references point to the same commit.
|
174
|
+
#
|
175
|
+
# @param ref1 [String] the first git reference to check.
|
176
|
+
# @param ref2 [String] the second git reference to check.
|
177
|
+
#
|
178
|
+
# @return [Boolean] true if the two references point to the same commit, false otherwise.
|
179
|
+
#
|
180
|
+
def self.point_to_same_commit?(ref1, ref2)
|
181
|
+
git_repo = Git.open(Dir.pwd)
|
182
|
+
|
183
|
+
begin
|
184
|
+
ref1_commit = git_repo.gcommit(ref1)
|
185
|
+
ref2_commit = git_repo.gcommit(ref2)
|
186
|
+
rescue StandardError => e
|
187
|
+
puts "Error: #{e.message}"
|
188
|
+
return false
|
189
|
+
end
|
190
|
+
|
191
|
+
ref1_commit.sha == ref2_commit.sha
|
192
|
+
end
|
193
|
+
|
182
194
|
# Returns the current git branch, or "HEAD" if it's not checked out to any branch
|
183
195
|
# Can NOT be replaced using the environment variables such as `GIT_BRANCH` or `BUILDKITE_BRANCH`
|
184
196
|
#
|
@@ -206,22 +218,15 @@ module Fastlane
|
|
206
218
|
!Action.sh('git', 'branch', '--list', branch_name).empty?
|
207
219
|
end
|
208
220
|
|
209
|
-
#
|
210
|
-
#
|
211
|
-
# @param [String] branch_name The name of the branch we expect to be on
|
221
|
+
# Checks if a branch exists on the repository's remote.
|
212
222
|
#
|
213
|
-
# @
|
223
|
+
# @param branch_name [String] the name of the branch to check.
|
224
|
+
# @param remote_name [String] the name of the remote repository (default is 'origin').
|
214
225
|
#
|
215
|
-
# @
|
216
|
-
# After updating to Fastlane version `2.217.0` or later, the `FL_GIT_BRANCH_DONT_USE_ENV_VARS` environment
|
217
|
-
# variable can be set to `true` to disable the use of environment variables for the `git_branch` action that
|
218
|
-
# `ensure_git_branch` relies on. This will make `ensure_git_branch` work as expected in CI environments.
|
219
|
-
# See https://github.com/fastlane/fastlane/pull/21597 for more details.
|
226
|
+
# @return [Boolean] true if the branch exists on remote, false otherwise.
|
220
227
|
#
|
221
|
-
def self.
|
222
|
-
|
223
|
-
current_branch_name = Action.sh('git', 'symbolic-ref', '-q', 'HEAD')
|
224
|
-
UI.user_error!("This command works only on #{branch_name} branch") unless current_branch_name.include?(branch_name)
|
228
|
+
def self.branch_exists_on_remote?(branch_name:, remote_name: 'origin')
|
229
|
+
!Action.sh('git', 'ls-remote', '--heads', remote_name, branch_name).empty?
|
225
230
|
end
|
226
231
|
|
227
232
|
# Checks whether a given path is ignored by Git, relying on Git's `check-ignore` under the hood.
|
@@ -186,7 +186,7 @@ module Fastlane
|
|
186
186
|
res.body
|
187
187
|
end
|
188
188
|
|
189
|
-
# Returns the URL of the GitHub release pointing at a given tag
|
189
|
+
# Returns the URL of the published GitHub release pointing at a given tag
|
190
190
|
# @param [String] repository The repository to create the GitHub release on. Typically a repo slug (<org>/<repo>).
|
191
191
|
# @param [String] tag_name The name of the git tag to get the associated release of
|
192
192
|
#
|
@@ -198,6 +198,31 @@ module Fastlane
|
|
198
198
|
nil
|
199
199
|
end
|
200
200
|
|
201
|
+
# Publishes an existing GitHub Release still in draft mode.
|
202
|
+
#
|
203
|
+
# @param [String] repository The repository name, including the organization (e.g. `wordpress-mobile/wordpress-ios`)
|
204
|
+
# @param [String] name The name of the release to publish.
|
205
|
+
# @param [Boolean] prerelease Indicates if this should be created as a pre-release (i.e. for alpha/beta)
|
206
|
+
#
|
207
|
+
# @return [String] URL of the corresponding GitHub Release
|
208
|
+
#
|
209
|
+
def publish_release(repository:, name:, prerelease: nil)
|
210
|
+
releases = client.releases(repository)
|
211
|
+
release = releases.find { |r| r.name == name }
|
212
|
+
|
213
|
+
UI.user_error!("No release found with name #{name}") unless release
|
214
|
+
|
215
|
+
client.update_release(
|
216
|
+
release.url,
|
217
|
+
{
|
218
|
+
draft: false,
|
219
|
+
prerelease: prerelease
|
220
|
+
}.compact
|
221
|
+
)
|
222
|
+
|
223
|
+
release.html_url
|
224
|
+
end
|
225
|
+
|
201
226
|
# Downloads a file from the given GitHub tag
|
202
227
|
#
|
203
228
|
# @param [String] repository The repository name (including the organization)
|