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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7c09abca8957f803d8c78260e14c3e7f7ce80a4482e34200a3c17e09cd55086
|
4
|
+
data.tar.gz: 9b13c63d00aae7a350c1372d4748a392d53faca2cd30424c9c0272208e3ed74e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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(
|
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,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(
|
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
|
+
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
|
-
|
79
|
-
|
80
|
-
|
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(
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
|
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.
|
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-
|
11
|
+
date: 2022-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|