fastlane-plugin-auto_version_name 0.1.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 786d23d7922236df9c7f658a188c82be0e19c6de2135742caf00089a24cfbe39
4
- data.tar.gz: 1b25b601ee511504b73ad010fdbf20c431af362946e43243b603a45298333f59
3
+ metadata.gz: 8f10a1f69013f98b7eed2528d10c4752aebbb4f4e724d49d89f0f8f9ae5d7588
4
+ data.tar.gz: cc11ee12661f56ed7edefdb21761a585922756b80874f37b5968c0f3c7db5b8f
5
5
  SHA512:
6
- metadata.gz: 21acb54c2d35390b0d109a1ac37abee5d87fa845fc4a490b1d10204c3574d399e2a47658d0817128292de3b9e99c059a252cb341a869e049acd726e953157de0
7
- data.tar.gz: d6767ad0df99cc1f2715ee2f12ec9bceb237fa9ee794952ea67823d61aeb57fe20a51f6b1f04ea4f328196ad82a56d31e207c022cb6ecfbe90f93298eda5e55e
6
+ metadata.gz: cce9bdf292e20c825da20d7df50d831032df7fb7742937e436efd7be56c7caa04965da9b30af6e1742f1d26d31276b1c0784300a09ce3b2315c005f3c6f2dadd
7
+ data.tar.gz: fc8f0069976b00b910b909a9136f6f31696ed111f0fd2f67d28fb35a3cc5b578be544eafbd696633b29d0075c50af560a43f9325eb4b2b0470109fc09a2741e1
data/README.md CHANGED
@@ -32,8 +32,15 @@ Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plu
32
32
  ```ruby
33
33
  platform :android do
34
34
  # [...]
35
+ root_directory = `cd ../.. && pwd`.chomp
36
+
37
+ package_name = "your.package.name"
38
+
35
39
  def get_live_version() # METHOD
36
- return google_play_track_release_names().first
40
+ return google_play_track_release_names(
41
+ json_key: "#{root_directory}/android/google-play-key.json",
42
+ package_name: package_name
43
+ ).first
37
44
  # main method returns an array by default. ["1.0.0"] => "1.0.0"
38
45
  end
39
46
  # [...]
@@ -100,10 +107,10 @@ platform :android do
100
107
  # [...]
101
108
  root_directory = `cd ../.. && pwd`.chomp
102
109
 
103
- ios_lane = import("../../ios/fastlane/Fastfile")
110
+ ios_lane = import("#{root_directory}/ios/fastlane/Fastfile")
104
111
 
105
112
  version = auto_version_name(
106
- minimal_version_string: File.open("#{root_directory}/version_name").read.chomp,
113
+ minimal_version: File.open("#{root_directory}/version_name").read.chomp,
107
114
  android_live_version: get_live_version(),
108
115
  ios_live_version: ios_lane.runner.execute("live_version_name", "ios"),
109
116
  # IMPORTANT: if your version lanes have the same name, you need to especify the platform on execute
@@ -132,7 +139,7 @@ platform :ios do
132
139
  android_lane = import("#{root_directory}/android/fastlane/Fastfile")
133
140
 
134
141
  version = auto_version_name(
135
- minimal_version_string: File.open("#{root_directory}/version_name").read.chomp,
142
+ minimal_version: File.open("#{root_directory}/version_name").read.chomp,
136
143
  ios_live_version: get_live_version(),
137
144
  android_live_version: android_lane.runner.execute("live_version_name", "android"),
138
145
  # IMPORTANT: if your version lanes have the same name, you need to especify the platform on execute
@@ -5,49 +5,90 @@ module Fastlane
5
5
  module Actions
6
6
  class AutoVersionNameAction < Action
7
7
  def self.run(params)
8
+ # INITIALIZE
9
+ branch = Actions.git_branch()
10
+ last_commit_message = Actions.last_git_commit_message()
11
+ final_version_array = []
12
+ final_version_string = ""
13
+ minimal_version_string = params[:minimal_version]
14
+ has_any_live_version = false
15
+
16
+ # FUNCTIONS
8
17
  def self.version_string_to_array(version_string)
9
18
  return version_string.split('.').map { |value| value.to_i }
10
19
  end
11
20
 
12
- def self.get_greater_version(version1, version2, version3)
21
+ def self.get_greater_version(minimal, ios, android)
13
22
  greater_version = ""
14
23
 
15
- version1 = version1 == nil ? "" : version1
16
- version2 = version2 == nil ? "" : version2
17
- version3 = version3 == nil ? "" : version3
24
+ minimal = minimal == nil ? "" : minimal
25
+ ios = ios == nil ? "" : ios
26
+ android = android == nil ? "" : android
18
27
 
19
- is_v1_greater = Gem::Version.new(version1) >= Gem::Version.new(version2) && Gem::Version.new(version1) >= Gem::Version.new(version3)
28
+ is_minimal_greater = Gem::Version.new(minimal) >= Gem::Version.new(ios) && Gem::Version.new(minimal) >= Gem::Version.new(android)
20
29
 
21
- is_v2_greater = Gem::Version.new(version2) >= Gem::Version.new(version1) && Gem::Version.new(version2) >= Gem::Version.new(version3)
30
+ is_ios_greater = Gem::Version.new(ios) >= Gem::Version.new(minimal) && Gem::Version.new(ios) >= Gem::Version.new(android)
22
31
 
23
- is_v3_greater = Gem::Version.new(version3) >= Gem::Version.new(version1) && Gem::Version.new(version3) >= Gem::Version.new(version2)
32
+ is_android_greater = Gem::Version.new(android) >= Gem::Version.new(minimal) && Gem::Version.new(android) >= Gem::Version.new(ios)
24
33
 
25
- if (is_v1_greater)
26
- greater_version = version1
27
- elsif (is_v2_greater)
28
- greater_version = version2
29
- elsif (is_v3_greater)
30
- greater_version = version3
34
+ if (is_minimal_greater)
35
+ greater_version = minimal
36
+ elsif (is_ios_greater)
37
+ greater_version = ios
38
+ elsif (is_android_greater)
39
+ greater_version = android
31
40
  end
32
41
 
33
42
  if (greater_version.empty? || greater_version == nil)
34
- greater_version = "1.0.0"
43
+ greater_version = minimal_version_string
35
44
  end
36
45
 
37
46
  return greater_version
47
+ end
48
+
49
+ # iOS
50
+ begin
51
+ AppStoreBuildNumberAction.run(
52
+ api_key: params[:ios_api_key],
53
+ app_identifier: params[:ios_app_identifier],
54
+ username: params[:ios_username],
55
+ team_id: params[:ios_team_id],
56
+ platform: "ios",
57
+ live: true,
58
+ )
59
+ ios_version_string = lane_context[SharedValues::LATEST_VERSION];
60
+ has_any_live_version = true
61
+
62
+ rescue => exception
63
+ puts exception
64
+ ios_version_string = minimal_version_string
38
65
  end
39
66
 
40
- # Initialize
41
- branch = Actions.git_branch()
42
- final_version_array = []
43
- final_version_string = ""
44
- minimal_version_string = params[:minimal_version]
45
- ios_version_string = params[:ios_live_version]
46
- android_version_string = params[:android_live_version]
47
-
48
- final_version_array = get_greater_version(
67
+ # ANDROID
68
+ begin
69
+ android_version_string = GooglePlayTrackReleaseNamesAction.run(
70
+ json_key: params[:android_json_key_path],
71
+ package_name: params[:android_package_name],
72
+ track: "production",
73
+ ).first
74
+ has_any_live_version = true
75
+
76
+ rescue => exception
77
+ puts exception
78
+ android_version_string = minimal_version_string
79
+ end
80
+
81
+ greater_version_string = get_greater_version(
49
82
  minimal_version_string, ios_version_string, android_version_string
50
- ).split('.').map { |value| value.to_i }
83
+ )
84
+
85
+ are_all_equal = [minimal_version_string, ios_version_string, android_version_string].uniq.size <= 1
86
+
87
+ if (!has_any_live_version || (!are_all_equal && greater_version_string == minimal_version_string))
88
+ return minimal_version_string
89
+ end
90
+
91
+ final_version_array = greater_version_string.split('.').map { |value| value.to_i }
51
92
 
52
93
  # Upgrade final version array and return
53
94
  major = final_version_array[0]
@@ -56,7 +97,7 @@ module Fastlane
56
97
 
57
98
  # Auto increment.
58
99
  # 1.0.1 => 1.0.1(+1) => 1.0.2 || 1.0.1 => 1.0(+1).1 => 1.1.0
59
- if (branch.include? 'hotfix')
100
+ if ((branch.include? 'hotfix') || (last_commit_message.include? 'hotfix'))
60
101
  patch += 1
61
102
  else
62
103
  minor += 1
@@ -75,13 +116,9 @@ module Fastlane
75
116
  major += 1
76
117
  end
77
118
 
78
- live_versions_not_setted = (ios_version_string == nil || ios_version_string.empty?) && (android_version_string == nil || android_version_string.empty?)
79
-
80
- unless (live_versions_not_setted)
81
- final_version_array[0] = major
82
- final_version_array[1] = minor
83
- final_version_array[2] = patch
84
- end
119
+ final_version_array[0] = major
120
+ final_version_array[1] = minor
121
+ final_version_array[2] = patch
85
122
 
86
123
  final_version_string = final_version_array.join('.') # [1, 0, 0] => "1.0.0"
87
124
  return final_version_string
@@ -106,21 +143,68 @@ module Fastlane
106
143
 
107
144
  def self.available_options
108
145
  [
109
- FastlaneCore::ConfigItem.new(key: :minimal_version,
110
- env_name: "MINIMAL_VERSION_STRING",
111
- description: "A minimal version to be set",
112
- optional: true,
113
- type: String),
114
- FastlaneCore::ConfigItem.new(key: :android_live_version,
115
- env_name: "ANDROID_LIVE_VERSION",
116
- description: "Android's live version name e.g. \"1.0.0\"",
117
- optional: true,
118
- type: String),
119
- FastlaneCore::ConfigItem.new(key: :ios_live_version,
120
- env_name: "IOS_LIVE_VERSION",
121
- description: "iOS's live version name e.g. \"1.0.0\"",
122
- optional: true,
123
- type: String),
146
+ FastlaneCore::ConfigItem.new(
147
+ key: :android_package_name,
148
+ env_name: "ANDROID_PACKAGE_NAME",
149
+ description: "The package_name of your android app",
150
+ optional: true,
151
+ type: String
152
+ ),
153
+ FastlaneCore::ConfigItem.new(
154
+ key: :ios_app_identifier,
155
+ env_name: "IOS_PACKAGE_NAME",
156
+ description: "The bundle_identifier of your iOS app",
157
+ optional: true,
158
+ type: String
159
+ ),
160
+ FastlaneCore::ConfigItem.new(
161
+ key: :minimal_version,
162
+ env_name: "MINIMAL_VERSION_STRING",
163
+ description: "A minimal version to be set",
164
+ optional: true,
165
+ default_value: "1.0.0",
166
+ type: String
167
+ ),
168
+ FastlaneCore::ConfigItem.new(
169
+ key: :android_json_key_path,
170
+ env_name: "ANDROID_JSON_KEY_PATH",
171
+ description: "The path to a file containing service account JSON, used to authenticate with Google",
172
+ optional: true,
173
+ type: String
174
+ ),
175
+ FastlaneCore::ConfigItem.new(
176
+ key: :ios_api_key,
177
+ env_names: ["APPSTORE_BUILD_NUMBER_API_KEY", "APP_STORE_CONNECT_API_KEY"],
178
+ description: "Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-hash-option)",
179
+ type: Hash,
180
+ default_value: Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APP_STORE_CONNECT_API_KEY],
181
+ default_value_dynamic: true,
182
+ optional: true,
183
+ sensitive: true,
184
+ conflicting_options: [:api_key_path]
185
+ ),
186
+ FastlaneCore::ConfigItem.new(
187
+ key: :ios_username,
188
+ short_option: "-u",
189
+ env_name: "ITUNESCONNECT_USER",
190
+ description: "Your Apple ID Username",
191
+ optional: true,
192
+ type: String
193
+ ),
194
+ FastlaneCore::ConfigItem.new(
195
+ key: :ios_team_id,
196
+ short_option: "-k",
197
+ env_name: "APPSTORE_BUILD_NUMBER_LIVE_TEAM_ID",
198
+ description: "The ID of your App Store Connect team if you're in multiple teams",
199
+ optional: true,
200
+ skip_type_validation: true, # as we also allow integers, which we convert to strings anyway
201
+ code_gen_sensitive: true,
202
+ default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id),
203
+ default_value_dynamic: true,
204
+ verify_block: proc do |value|
205
+ ENV["FASTLANE_ITC_TEAM_ID"] = value.to_s
206
+ end
207
+ ),
124
208
  ]
125
209
  end
126
210
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AutoVersionName
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-auto_version_name
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - gileadeteixeira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-30 00:00:00.000000000 Z
11
+ date: 2022-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -181,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
183
  requirements: []
184
- rubygems_version: 3.0.9
184
+ rubygems_version: 3.3.25
185
185
  signing_key:
186
186
  specification_version: 4
187
187
  summary: Generate incremented version names from Apple and Google stores