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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f10a1f69013f98b7eed2528d10c4752aebbb4f4e724d49d89f0f8f9ae5d7588
|
4
|
+
data.tar.gz: cc11ee12661f56ed7edefdb21761a585922756b80874f37b5968c0f3c7db5b8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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("
|
110
|
+
ios_lane = import("#{root_directory}/ios/fastlane/Fastfile")
|
104
111
|
|
105
112
|
version = auto_version_name(
|
106
|
-
|
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
|
-
|
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(
|
21
|
+
def self.get_greater_version(minimal, ios, android)
|
13
22
|
greater_version = ""
|
14
23
|
|
15
|
-
|
16
|
-
|
17
|
-
|
24
|
+
minimal = minimal == nil ? "" : minimal
|
25
|
+
ios = ios == nil ? "" : ios
|
26
|
+
android = android == nil ? "" : android
|
18
27
|
|
19
|
-
|
28
|
+
is_minimal_greater = Gem::Version.new(minimal) >= Gem::Version.new(ios) && Gem::Version.new(minimal) >= Gem::Version.new(android)
|
20
29
|
|
21
|
-
|
30
|
+
is_ios_greater = Gem::Version.new(ios) >= Gem::Version.new(minimal) && Gem::Version.new(ios) >= Gem::Version.new(android)
|
22
31
|
|
23
|
-
|
32
|
+
is_android_greater = Gem::Version.new(android) >= Gem::Version.new(minimal) && Gem::Version.new(android) >= Gem::Version.new(ios)
|
24
33
|
|
25
|
-
if (
|
26
|
-
greater_version =
|
27
|
-
elsif (
|
28
|
-
greater_version =
|
29
|
-
elsif (
|
30
|
-
greater_version =
|
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 =
|
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
|
-
#
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
)
|
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
|
-
|
79
|
-
|
80
|
-
|
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(
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
|
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
|
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-
|
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.
|
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
|