fastlane-plugin-wpmreleasetoolkit 11.1.0 → 12.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_create_xml_release_notes.rb +0 -2
  3. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_current_branch_is_hotfix.rb +1 -9
  4. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/close_milestone_action.rb +0 -2
  5. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/{create_release_action.rb → create_github_release_action.rb} +1 -3
  6. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_new_milestone_action.rb +0 -1
  7. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_backmerge_pull_request_action.rb +4 -1
  8. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb +63 -0
  9. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_check_beta_deps.rb +0 -3
  10. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_version_helper.rb +2 -373
  11. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/git_helper.rb +8 -29
  12. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +26 -1
  13. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_version_helper.rb +0 -270
  14. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/metadata/release_note_short_metadata_block.rb +2 -2
  15. data/lib/fastlane/plugin/wpmreleasetoolkit/version.rb +1 -1
  16. metadata +8 -58
  17. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_betabuild_prechecks.rb +0 -137
  18. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_build_prechecks.rb +0 -108
  19. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_beta.rb +0 -90
  20. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_final_release.rb +0 -82
  21. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_hotfix.rb +0 -91
  22. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_bump_version_release.rb +0 -109
  23. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_codefreeze_prechecks.rb +0 -108
  24. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_completecodefreeze_prechecks.rb +0 -86
  25. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_finalize_prechecks.rb +0 -89
  26. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_alpha_version.rb +0 -62
  27. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_app_version.rb +0 -62
  28. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_get_release_version.rb +0 -62
  29. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_hotfix_prechecks.rb +0 -78
  30. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/android/android_tag_build.rb +0 -70
  31. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_betabuild_prechecks.rb +0 -98
  32. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_build_prechecks.rb +0 -74
  33. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_beta.rb +0 -67
  34. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_hotfix.rb +0 -83
  35. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_bump_version_release.rb +0 -87
  36. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_codefreeze_prechecks.rb +0 -76
  37. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_completecodefreeze_prechecks.rb +0 -65
  38. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_current_branch_is_hotfix.rb +0 -40
  39. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_finalize_prechecks.rb +0 -66
  40. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_app_version.rb +0 -54
  41. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_number.rb +0 -54
  42. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_get_build_version.rb +0 -60
  43. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_hotfix_prechecks.rb +0 -78
  44. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_tag_build.rb +0 -44
  45. data/lib/fastlane/plugin/wpmreleasetoolkit/actions/ios/ios_validate_ci_build.rb +0 -46
  46. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/android/android_git_helper.rb +0 -28
  47. data/lib/fastlane/plugin/wpmreleasetoolkit/helper/ios/ios_git_helper.rb +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f9d86b44058a8ff2f28f2c56bdb81230395e36eac41f6e4d0761140f9694177
4
- data.tar.gz: cc234c6029919a63d4d9ed2114d390bb58ad79e67f7ae1650e94b23cfac92bc9
3
+ metadata.gz: 2f4bad14f2aca7e44fede245ed91674426c688395c9d6a5085a4d25a5e30e361
4
+ data.tar.gz: 66e0440a5340b12dff4a5e35c37759c48d04c8f157e83e4c57ca94cde2c4135e
5
5
  SHA512:
6
- metadata.gz: e2e86d40c624300445ddc600e19b8b16a560e86725c82344719bbbadb69ad0c1552fff4f951cdb5411d892973fa37b524b47bcc99b0d14a23bff56607d44f676
7
- data.tar.gz: faf08e93483cced02d83d705b9cff2843e07244c708312bdf8dfb86131b2990d4e5ba94397aa71aadd8a3cb6d485da2007b5743950e15486ff81243f8a956b35
6
+ metadata.gz: 1ed67cfa98a54dfe351d5e90ac318f97f1d40d777ac498f427b7c417f32651f16574eb441de44730ef5a7299edef57b096137b06ab64a4964aca56d072e7a0c0
7
+ data.tar.gz: a698dc1828a99415b4b88b373541ad20b264933cb2d13b0c65b2efd6c4608361b40bb0dca4756f9a518dee3a9e7fa4f8c43e142dfb3a50bba391398f76744bd5
@@ -2,8 +2,6 @@ module Fastlane
2
2
  module Actions
3
3
  class AndroidCreateXmlReleaseNotesAction < Action
4
4
  def self.run(params)
5
- require_relative '../../helper/android/android_git_helper'
6
-
7
5
  release_notes_path = "#{params[:download_path]}/release_notes.xml"
8
6
  open(release_notes_path, 'w') do |f|
9
7
  params[:locales].each do |loc|
@@ -8,11 +8,9 @@ module Fastlane
8
8
  def self.run(params)
9
9
  require_relative '../../helper/android/android_version_helper'
10
10
 
11
- build_gradle_path = params[:build_gradle_path]
12
11
  version_properties_path = params[:version_properties_path]
13
12
 
14
13
  version = Fastlane::Helper::Android::VersionHelper.get_release_version(
15
- build_gradle_path: build_gradle_path,
16
14
  version_properties_path: version_properties_path
17
15
  )
18
16
  Fastlane::Helper::Android::VersionHelper.is_hotfix?(version)
@@ -32,16 +30,10 @@ module Fastlane
32
30
 
33
31
  def self.available_options
34
32
  [
35
- FastlaneCore::ConfigItem.new(key: :build_gradle_path,
36
- description: 'Path to the build.gradle file',
37
- type: String,
38
- optional: true,
39
- conflicting_options: [:version_properties_path]),
40
33
  FastlaneCore::ConfigItem.new(key: :version_properties_path,
41
34
  description: 'Path to the version.properties file',
42
35
  type: String,
43
- optional: true,
44
- conflicting_options: [:build_gradle_path]),
36
+ optional: false),
45
37
  ]
46
38
  end
47
39
 
@@ -1,8 +1,6 @@
1
1
  require 'fastlane/action'
2
2
  require 'date'
3
3
  require_relative '../../helper/github_helper'
4
- require_relative '../../helper/ios/ios_version_helper'
5
- require_relative '../../helper/android/android_version_helper'
6
4
  module Fastlane
7
5
  module Actions
8
6
  class CloseMilestoneAction < Action
@@ -1,11 +1,9 @@
1
1
  require 'fastlane/action'
2
2
  require 'date'
3
3
  require_relative '../../helper/github_helper'
4
- require_relative '../../helper/ios/ios_version_helper'
5
- require_relative '../../helper/android/android_version_helper'
6
4
  module Fastlane
7
5
  module Actions
8
- class CreateReleaseAction < Action
6
+ class CreateGithubReleaseAction < Action
9
7
  def self.run(params)
10
8
  repository = params[:repository]
11
9
  version = params[:version]
@@ -2,7 +2,6 @@ require 'fastlane/action'
2
2
  require 'date'
3
3
  require_relative '../../helper/github_helper'
4
4
  require_relative '../../helper/ios/ios_version_helper'
5
- require_relative '../../helper/android/android_version_helper'
6
5
  module Fastlane
7
6
  module Actions
8
7
  class CreateNewMilestoneAction < Action
@@ -103,7 +103,10 @@ module Fastlane
103
103
  # if there's a callback, make sure it didn't switch branches
104
104
  other_action.ensure_git_branch(branch: "^#{intermediate_branch}/") unless intermediate_branch_created_callback.nil?
105
105
 
106
- if Fastlane::Helper::GitHelper.point_to_same_commit?(base_branch, head_branch)
106
+ base_branch_ref = base_branch.start_with?('origin/') ? base_branch : "origin/#{base_branch}"
107
+ head_branch_ref = head_branch.start_with?('origin/') ? head_branch : "origin/#{head_branch}"
108
+
109
+ if Fastlane::Helper::GitHelper.point_to_same_commit?(base_branch_ref, head_branch_ref)
107
110
  UI.error("No differences between #{head_branch} and #{base_branch}. Skipping PR creation.")
108
111
  return nil
109
112
  end
@@ -0,0 +1,63 @@
1
+ require 'fastlane/action'
2
+ require_relative '../../helper/github_helper'
3
+
4
+ module Fastlane
5
+ module Actions
6
+ class PublishGithubReleaseAction < Action
7
+ def self.run(params)
8
+ repository = params[:repository]
9
+ name = params[:name]
10
+ prerelease = params[:prerelease]
11
+
12
+ github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token])
13
+
14
+ url = github_helper.publish_release(
15
+ repository: repository,
16
+ name: name,
17
+ prerelease: prerelease == :unchanged ? nil : prerelease
18
+ )
19
+ UI.success("Successfully published GitHub Release #{name}. You can see it at '#{url}'")
20
+ url
21
+ end
22
+
23
+ def self.description
24
+ 'Publish an existing GitHub Release still in draft mode'
25
+ end
26
+
27
+ def self.authors
28
+ ['Automattic']
29
+ end
30
+
31
+ def self.return_value
32
+ 'The URL of the published GitHub Release'
33
+ end
34
+
35
+ def self.details
36
+ 'Publish an existing GitHub Release still in draft mode'
37
+ end
38
+
39
+ def self.available_options
40
+ [
41
+ FastlaneCore::ConfigItem.new(key: :repository,
42
+ description: 'The slug (`<org>/<repo>`) of the GitHub repository we want to create the release on',
43
+ optional: false,
44
+ type: String),
45
+ FastlaneCore::ConfigItem.new(key: :name,
46
+ description: 'The name (aka title) of the draft release to publish',
47
+ optional: false,
48
+ type: String),
49
+ FastlaneCore::ConfigItem.new(key: :prerelease,
50
+ description: 'True to publish as a pre-release. False to published as final. Don\'t provide a value to keep the same (non-)prerelease status as the one used in the Draft',
51
+ optional: true,
52
+ default_value: :unchanged,
53
+ type: Boolean),
54
+ Fastlane::Helper::GithubHelper.github_token_config_item,
55
+ ]
56
+ end
57
+
58
+ def self.is_supported?(platform)
59
+ true
60
+ end
61
+ end
62
+ end
63
+ end
@@ -7,9 +7,6 @@ module Fastlane
7
7
  NON_STABLE_PODS_MESSAGE = "Please create a new stable version of those pods and update the Podfile to the newly released version before continuing with the code freeze:\n".freeze
8
8
 
9
9
  def self.run(params)
10
- require_relative '../../helper/ios/ios_version_helper'
11
- require_relative '../../helper/ios/ios_git_helper'
12
-
13
10
  yaml = YAML.load_file(params[:lockfile])
14
11
  non_stable_pods = {} # Key will be pod name, value will be reason for flagging
15
12
 
@@ -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(build_gradle_path:, version_properties_path:)
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 is_alpha_version?(version)
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.
@@ -188,8 +179,14 @@ module Fastlane
188
179
  #
189
180
  def self.point_to_same_commit?(ref1, ref2)
190
181
  git_repo = Git.open(Dir.pwd)
191
- ref1_commit = git_repo.gcommit(ref1)
192
- ref2_commit = git_repo.gcommit(ref2)
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
193
190
 
194
191
  ref1_commit.sha == ref2_commit.sha
195
192
  end
@@ -232,24 +229,6 @@ module Fastlane
232
229
  !Action.sh('git', 'ls-remote', '--heads', remote_name, branch_name).empty?
233
230
  end
234
231
 
235
- # Ensure that we are on the expected branch, and abort if not.
236
- #
237
- # @param [String] branch_name The name of the branch we expect to be on
238
- #
239
- # @raise [UserError] Raises a user_error! and interrupts the lane if we are not on the expected branch.
240
- #
241
- # @deprecated This method is going to be removed soon. Fastlane has a built-in `ensure_git_branch` action that can be used instead.
242
- # After updating to Fastlane version `2.217.0` or later, the `FL_GIT_BRANCH_DONT_USE_ENV_VARS` environment
243
- # variable can be set to `true` to disable the use of environment variables for the `git_branch` action that
244
- # `ensure_git_branch` relies on. This will make `ensure_git_branch` work as expected in CI environments.
245
- # See https://github.com/fastlane/fastlane/pull/21597 for more details.
246
- #
247
- def self.ensure_on_branch!(branch_name)
248
- UI.deprecated("The `ensure_on_branch!` method will soon be removed from `release-toolkit`. Please use fastlane's `ensure_git_branch` action (+ potentially set `FL_GIT_BRANCH_DONT_USE_ENV_VARS=true`) instead.")
249
- current_branch_name = Action.sh('git', 'symbolic-ref', '-q', 'HEAD')
250
- UI.user_error!("This command works only on #{branch_name} branch") unless current_branch_name.include?(branch_name)
251
- end
252
-
253
232
  # Checks whether a given path is ignored by Git, relying on Git's `check-ignore` under the hood.
254
233
  #
255
234
  # @param [String] path The path to check against `.gitignore`