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: 46a421823a54191491c99165bfb40ca29e0232b57bac26bbaa28d6a2cec3176c
4
- data.tar.gz: bad930d84f304fea0eb753cd67ea2e02085fd66ea4047f85f3e87bed626c11e2
3
+ metadata.gz: ebd9b1458de12f0fbb8b468d79442ee341944409847c9f216cb04209930d9b15
4
+ data.tar.gz: 7539e1e186f06a3a43343a17cd7a584e0471ae3e812f75b9b53563bd7c8e8763
5
5
  SHA512:
6
- metadata.gz: d48f56c4ee2ad3464c0b6d79dc72f7a66e065a5640d8db95d3b93afcff253728f223421c1e91d9e00c4868ba48107fc8f42fbcb4f87c10b6c4da5933142f1341
7
- data.tar.gz: e0369425848c3284c7fa3901f810dd5ec7a6fd33ce73ce8277d46669a19c1e5c1017aa218dfd04f594c897bf70b95f2d8fd16282a298396673872a00a27d47fb
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
- MATCH_KEYSTORE_ALIAS_PASSWORD = :MATCH_KEYSTORE_ALIAS_PASSWORD
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
- puts `rm -f android_home.txt`
36
- puts `echo $ANDROID_HOME > android_home.txt`
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
- puts `rm -f android_home.txt`
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
- puts `rm -f #{key_path}`
58
- puts `echo "#{password}" | openssl dgst -sha512 | cut -c1-128 > #{key_path}`
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
- puts `rm -f #{encrypt_file}`
63
- puts `openssl enc -aes-256-cbc -salt -in #{clear_file} -out #{encrypt_file} -pass file:#{key_path}`
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
- puts `rm -f #{clear_file}`
68
- puts `openssl enc -d -aes-256-cbc -in #{encrypt_file} -out #{clear_file} -pass file:#{key_path}`
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
- puts `rm -f #{apk_path_aligned}`
79
- puts `#{build_tools_path}zipalign 4 #{apk_path} #{apk_path_aligned}`
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
- puts `rm -f #{apk_path_signed}`
87
- puts `#{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}`
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
- puts `#{build_tools_path}apksigner verify #{apk_path_signed}`
90
- puts `rm -f #{apk_path_aligned}`
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 repository directory...")
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 `git clone #{git_url} #{repo_dir}`
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
- puts `cp #{existing_keystore} #{keystore_path}`
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
- puts `cd #{repo_dir} && git add .`
240
- puts `cd #{repo_dir} && git commit -m "[ADD] Keystore for app '#{package_name}'."`
241
- puts `cd #{repo_dir} && git push`
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
- ['MATCH_KEYSTORE_PASSWORD', 'Keystore password.'],
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
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module MatchKeystore
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-match_keystore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher NEY