fastlane-plugin-match_keystore 0.1.5 → 0.1.6
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: ebd9b1458de12f0fbb8b468d79442ee341944409847c9f216cb04209930d9b15
|
4
|
+
data.tar.gz: 7539e1e186f06a3a43343a17cd7a584e0471ae3e812f75b9b53563bd7c8e8763
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 705abd50aa3502788519a81b51df38a6b6859b33cf2e4939f155eebda99ae1126e5be0f21426f158895cd19983d25dc017d499cf755a765de7abb3368b3b8ff6
|
7
|
+
data.tar.gz: a86e82117bcdf635a6a9253cdd6f89f1cfe223e57f95d43f816c200ff4a9b5b2c6e91396526dc1b9d08f30f8c35e9f8f9a4f3dfba432a787f20fb51c0a3da2f0
|
@@ -6,9 +6,8 @@ module Fastlane
|
|
6
6
|
module Actions
|
7
7
|
module SharedValues
|
8
8
|
MATCH_KEYSTORE_PATH = :MATCH_KEYSTORE_PATH
|
9
|
-
MATCH_KEYSTORE_PASSWORD = :MATCH_KEYSTORE_PASSWORD
|
10
9
|
MATCH_KEYSTORE_ALIAS_NAME = :MATCH_KEYSTORE_ALIAS_NAME
|
11
|
-
|
10
|
+
MATCH_KEYSTORE_APK_SIGNED = :MATCH_KEYSTORE_APK_SIGNED
|
12
11
|
end
|
13
12
|
|
14
13
|
class MatchKeystoreAction < Action
|
@@ -32,11 +31,11 @@ module Fastlane
|
|
32
31
|
end
|
33
32
|
|
34
33
|
def self.get_android_home
|
35
|
-
|
36
|
-
|
34
|
+
`rm -f android_home.txt`
|
35
|
+
`echo $ANDROID_HOME > android_home.txt`
|
37
36
|
data = File.read("android_home.txt")
|
38
37
|
android_home = data.strip
|
39
|
-
|
38
|
+
`rm -f android_home.txt`
|
40
39
|
android_home
|
41
40
|
end
|
42
41
|
|
@@ -54,18 +53,18 @@ module Fastlane
|
|
54
53
|
end
|
55
54
|
|
56
55
|
def self.gen_key(key_path, password)
|
57
|
-
|
58
|
-
|
56
|
+
`rm -f #{key_path}`
|
57
|
+
`echo "#{password}" | openssl dgst -sha512 | cut -c1-128 > #{key_path}`
|
59
58
|
end
|
60
59
|
|
61
60
|
def self.encrypt_file(clear_file, encrypt_file, key_path)
|
62
|
-
|
63
|
-
|
61
|
+
`rm -f #{encrypt_file}`
|
62
|
+
`openssl enc -aes-256-cbc -salt -in #{clear_file} -out #{encrypt_file} -pass file:#{key_path}`
|
64
63
|
end
|
65
64
|
|
66
65
|
def self.decrypt_file(encrypt_file, clear_file, key_path)
|
67
|
-
|
68
|
-
|
66
|
+
`rm -f #{clear_file}`
|
67
|
+
`openssl enc -d -aes-256-cbc -in #{encrypt_file} -out #{clear_file} -pass file:#{key_path}`
|
69
68
|
end
|
70
69
|
|
71
70
|
def self.sign_apk(apk_path, keystore_path, key_password, alias_name, alias_password, zip_align)
|
@@ -75,23 +74,28 @@ module Fastlane
|
|
75
74
|
# https://developer.android.com/studio/command-line/zipalign
|
76
75
|
if zip_align == true
|
77
76
|
apk_path_aligned = apk_path.gsub(".apk", "-aligned.apk")
|
78
|
-
|
79
|
-
|
77
|
+
`rm -f #{apk_path_aligned}`
|
78
|
+
`#{build_tools_path}zipalign 4 #{apk_path} #{apk_path_aligned}`
|
80
79
|
else
|
81
80
|
apk_path_aligned = apk_path
|
82
81
|
end
|
83
82
|
|
84
83
|
# https://developer.android.com/studio/command-line/apksigner
|
85
84
|
apk_path_signed = apk_path.gsub(".apk", "-signed.apk")
|
86
|
-
|
87
|
-
|
85
|
+
`rm -f #{apk_path_signed}`
|
86
|
+
`#{build_tools_path}apksigner sign --ks #{keystore_path} --ks-key-alias '#{alias_name}' --ks-pass pass:'#{alias_password}' --key-pass pass:'#{key_password}' --v1-signing-enabled true --v2-signing-enabled true --out #{apk_path_signed} #{apk_path_aligned}`
|
88
87
|
|
89
|
-
|
90
|
-
|
88
|
+
`#{build_tools_path}apksigner verify #{apk_path_signed}`
|
89
|
+
`rm -f #{apk_path_aligned}`
|
91
90
|
|
92
91
|
apk_path_signed
|
93
92
|
end
|
94
93
|
|
94
|
+
def self.get_file_content(file_path)
|
95
|
+
data = File.read(file_path)
|
96
|
+
data
|
97
|
+
end
|
98
|
+
|
95
99
|
def self.resolve_apk_path(apk_path)
|
96
100
|
|
97
101
|
if !apk_path.to_s.end_with?(".apk")
|
@@ -132,6 +136,7 @@ module Fastlane
|
|
132
136
|
|
133
137
|
keystore_name = 'keystore.jks'
|
134
138
|
properties_name = 'keystore.properties'
|
139
|
+
keystore_info_name = 'keystore.txt'
|
135
140
|
properties_encrypt_name = 'keystore.properties.enc'
|
136
141
|
|
137
142
|
# Check Android Home env:
|
@@ -154,19 +159,26 @@ module Fastlane
|
|
154
159
|
else
|
155
160
|
security_password = ci_password
|
156
161
|
end
|
162
|
+
UI.message "Generating security key..."
|
157
163
|
self.gen_key(key_path, security_password)
|
164
|
+
else
|
165
|
+
UI.message "Security key already exists"
|
158
166
|
end
|
167
|
+
tmpkey = self.get_file_content(key_path).strip
|
168
|
+
UI.message "Key: '#{tmpkey}'"
|
159
169
|
|
160
170
|
repo_dir = dir_name + '/repo'
|
161
171
|
unless File.directory?(repo_dir)
|
162
|
-
UI.message("Creating
|
172
|
+
UI.message("Creating 'repo' directory...")
|
163
173
|
FileUtils.mkdir_p(repo_dir)
|
164
174
|
end
|
165
175
|
|
166
176
|
gitDir = repo_dir + '/.git'
|
167
177
|
unless File.directory?(gitDir)
|
168
178
|
UI.message("Cloning remote Keystores repository...")
|
169
|
-
puts
|
179
|
+
puts ''
|
180
|
+
`git clone #{git_url} #{repo_dir}`
|
181
|
+
puts ''
|
170
182
|
end
|
171
183
|
|
172
184
|
keystoreAppDir = repo_dir + '/' + package_name
|
@@ -214,7 +226,7 @@ module Fastlane
|
|
214
226
|
sh keytool_parts.join(" ")
|
215
227
|
else
|
216
228
|
UI.message("Copy existing keystore to match_keystore repository...")
|
217
|
-
|
229
|
+
`cp #{existing_keystore} #{keystore_path}`
|
218
230
|
end
|
219
231
|
|
220
232
|
UI.message("Generating Keystore properties...")
|
@@ -234,11 +246,15 @@ module Fastlane
|
|
234
246
|
|
235
247
|
self.encrypt_file(properties_path, properties_encrypt_path, key_path)
|
236
248
|
File.delete(properties_path)
|
249
|
+
|
250
|
+
# Print Keystore data in repo:
|
251
|
+
keystore_info_path = keystoreAppDir + '/' + keystore_info_name
|
252
|
+
`yes "" | keytool -list -v -keystore #{keystore_path} > #{keystore_info_path}`
|
237
253
|
|
238
254
|
UI.message("Upload new Keystore to remote repository...")
|
239
|
-
|
240
|
-
|
241
|
-
|
255
|
+
`cd #{repo_dir} && git add .`
|
256
|
+
`cd #{repo_dir} && git commit -m "[ADD] Keystore for app '#{package_name}'."`
|
257
|
+
`cd #{repo_dir} && git push`
|
242
258
|
|
243
259
|
else
|
244
260
|
UI.message "Keystore file already exists, continue..."
|
@@ -254,12 +270,6 @@ module Fastlane
|
|
254
270
|
|
255
271
|
end
|
256
272
|
|
257
|
-
UI.message("Preparing Keystore data context...")
|
258
|
-
Actions.lane_context[SharedValues::MATCH_KEYSTORE_PATH] = keystore_path
|
259
|
-
Actions.lane_context[SharedValues::MATCH_KEYSTORE_PASSWORD] = key_password
|
260
|
-
Actions.lane_context[SharedValues::MATCH_KEYSTORE_ALIAS_NAME] = alias_name
|
261
|
-
Actions.lane_context[SharedValues::MATCH_KEYSTORE_ALIAS_PASSWORD] = alias_password
|
262
|
-
|
263
273
|
output_signed_apk = ''
|
264
274
|
apk_path = self.resolve_apk_path(apk_path)
|
265
275
|
|
@@ -282,6 +292,10 @@ module Fastlane
|
|
282
292
|
UI.message("No APK file found to sign!")
|
283
293
|
end
|
284
294
|
|
295
|
+
Actions.lane_context[SharedValues::MATCH_KEYSTORE_PATH] = keystore_path
|
296
|
+
Actions.lane_context[SharedValues::MATCH_KEYSTORE_ALIAS_NAME] = alias_name
|
297
|
+
Actions.lane_context[SharedValues::MATCH_KEYSTORE_APK_SIGNED] = output_signed_apk
|
298
|
+
|
285
299
|
output_signed_apk
|
286
300
|
|
287
301
|
end
|
@@ -301,9 +315,7 @@ module Fastlane
|
|
301
315
|
def self.output
|
302
316
|
[
|
303
317
|
['MATCH_KEYSTORE_PATH', 'File path of the Keystore fot the App.'],
|
304
|
-
['
|
305
|
-
['MATCH_KEYSTORE_ALIAS_NAME', 'Keystore Alias Name.'],
|
306
|
-
['MATCH_KEYSTORE_ALIAS_PASSWORD', 'Keystore Alias Password.']
|
318
|
+
['MATCH_KEYSTORE_ALIAS_NAME', 'Keystore Alias Name.']
|
307
319
|
]
|
308
320
|
end
|
309
321
|
|