fastlane-plugin-auto_version_name 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 786d23d7922236df9c7f658a188c82be0e19c6de2135742caf00089a24cfbe39
4
- data.tar.gz: 1b25b601ee511504b73ad010fdbf20c431af362946e43243b603a45298333f59
3
+ metadata.gz: f7c09abca8957f803d8c78260e14c3e7f7ce80a4482e34200a3c17e09cd55086
4
+ data.tar.gz: 9b13c63d00aae7a350c1372d4748a392d53faca2cd30424c9c0272208e3ed74e
5
5
  SHA512:
6
- metadata.gz: 21acb54c2d35390b0d109a1ac37abee5d87fa845fc4a490b1d10204c3574d399e2a47658d0817128292de3b9e99c059a252cb341a869e049acd726e953157de0
7
- data.tar.gz: d6767ad0df99cc1f2715ee2f12ec9bceb237fa9ee794952ea67823d61aeb57fe20a51f6b1f04ea4f328196ad82a56d31e207c022cb6ecfbe90f93298eda5e55e
6
+ metadata.gz: 63e01ee2984bc620921501ef862a4c8b8ef58ee6ae04c6b38588a53b5aa7d1b76af4ee643f530585d43bbb2ee4fa506bf1ce4b97d5a66a5dd9460a23ae5c58ae
7
+ data.tar.gz: 1c3e91b93bd0a39dbc83935b0c8d0734fed76f3036789eb6e2bae11b21db0126ea2eb2d9ef17ed72f9d484b3a84eba92b6965ff2e180c9c62b0fabf2bb2c5bf0
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,88 @@ 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
+ if (!has_any_live_version || greater_version_string == minimal_version_string)
86
+ return minimal_version_string
87
+ end
88
+
89
+ final_version_array = greater_version_string.split('.').map { |value| value.to_i }
51
90
 
52
91
  # Upgrade final version array and return
53
92
  major = final_version_array[0]
@@ -56,7 +95,7 @@ module Fastlane
56
95
 
57
96
  # Auto increment.
58
97
  # 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')
98
+ if ((branch.include? 'hotfix') || (last_commit_message.include? 'hotfix'))
60
99
  patch += 1
61
100
  else
62
101
  minor += 1
@@ -75,13 +114,9 @@ module Fastlane
75
114
  major += 1
76
115
  end
77
116
 
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
117
+ final_version_array[0] = major
118
+ final_version_array[1] = minor
119
+ final_version_array[2] = patch
85
120
 
86
121
  final_version_string = final_version_array.join('.') # [1, 0, 0] => "1.0.0"
87
122
  return final_version_string
@@ -106,21 +141,68 @@ module Fastlane
106
141
 
107
142
  def self.available_options
108
143
  [
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),
144
+ FastlaneCore::ConfigItem.new(
145
+ key: :android_package_name,
146
+ env_name: "ANDROID_PACKAGE_NAME",
147
+ description: "The package_name of your android app",
148
+ optional: true,
149
+ type: String
150
+ ),
151
+ FastlaneCore::ConfigItem.new(
152
+ key: :ios_app_identifier,
153
+ env_name: "IOS_PACKAGE_NAME",
154
+ description: "The bundle_identifier of your iOS app",
155
+ optional: true,
156
+ type: String
157
+ ),
158
+ FastlaneCore::ConfigItem.new(
159
+ key: :minimal_version,
160
+ env_name: "MINIMAL_VERSION_STRING",
161
+ description: "A minimal version to be set",
162
+ optional: true,
163
+ default_value: "1.0.0",
164
+ type: String
165
+ ),
166
+ FastlaneCore::ConfigItem.new(
167
+ key: :android_json_key_path,
168
+ env_name: "ANDROID_JSON_KEY_PATH",
169
+ description: "The path to a file containing service account JSON, used to authenticate with Google",
170
+ optional: true,
171
+ type: String
172
+ ),
173
+ FastlaneCore::ConfigItem.new(
174
+ key: :ios_api_key,
175
+ env_names: ["APPSTORE_BUILD_NUMBER_API_KEY", "APP_STORE_CONNECT_API_KEY"],
176
+ description: "Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-hash-option)",
177
+ type: Hash,
178
+ default_value: Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APP_STORE_CONNECT_API_KEY],
179
+ default_value_dynamic: true,
180
+ optional: true,
181
+ sensitive: true,
182
+ conflicting_options: [:api_key_path]
183
+ ),
184
+ FastlaneCore::ConfigItem.new(
185
+ key: :ios_username,
186
+ short_option: "-u",
187
+ env_name: "ITUNESCONNECT_USER",
188
+ description: "Your Apple ID Username",
189
+ optional: true,
190
+ type: String
191
+ ),
192
+ FastlaneCore::ConfigItem.new(
193
+ key: :ios_team_id,
194
+ short_option: "-k",
195
+ env_name: "APPSTORE_BUILD_NUMBER_LIVE_TEAM_ID",
196
+ description: "The ID of your App Store Connect team if you're in multiple teams",
197
+ optional: true,
198
+ skip_type_validation: true, # as we also allow integers, which we convert to strings anyway
199
+ code_gen_sensitive: true,
200
+ default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id),
201
+ default_value_dynamic: true,
202
+ verify_block: proc do |value|
203
+ ENV["FASTLANE_ITC_TEAM_ID"] = value.to_s
204
+ end
205
+ ),
124
206
  ]
125
207
  end
126
208
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module AutoVersionName
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
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.0
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-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler