fastlane-plugin-match_keystore 0.2.0 → 0.2.1

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: 554236b09184bb0b50f9209ae0de3ba469e58bd66a5c0cc28880e8e259f3721a
4
- data.tar.gz: b6c33c5ec05a4f72e2cbc04db6e64b2048b361408bedbaa9fe58e52908cbc5b3
3
+ metadata.gz: 13f57b6db57c10e142d53885360cb1416f676402fd7f234b61a549720501d9c6
4
+ data.tar.gz: 2809854cf748f5ba4931fd4cbe8dfc6292cfea2f4e5d556a887ed422ebfcacc2
5
5
  SHA512:
6
- metadata.gz: f99fe0dbb68617919711aaded1054d931a85dbc8730f2ac69fd289341389014fb02a25cc58b833c148991e85bb871cf360450821cff284427c60c6d7000f0f42
7
- data.tar.gz: c9de35e3c6cae52e1dca0d78823079f1239bc890df3c5865fb288f1fbe666e181ddba39d5de9136bb82622bdfc380c79b5b045907ca2e5d5df95df87448222b4
6
+ metadata.gz: 97a47758d5a39ebf414ae7a232e8767cb0dfa6ac7c484f3180b8e3149d3e879fb3ce3b27d363eae444703e9f3a9bad5b4ddc5d66f2987ed5fa0ed29b04bd4c74
7
+ data.tar.gz: 2c27e6a39112bdef3c44c6ed8abd77a31e19c9ce52a002040562d9f4aee229b4cf0e60cbe868196493acc983ca61b39acdfadebd2914e5a9ba15d40dd1024751
data/README.md CHANGED
@@ -50,6 +50,8 @@ The keystore properties are encrypted with AES in order to secure sensitive data
50
50
  end
51
51
  ```
52
52
 
53
+ You can build aab files as well by providing an `aab_path` instead of an `apk_path`.
54
+
53
55
  ## Example
54
56
 
55
57
  Check out the [example `Fastfile`](fastlane/Fastfile) to see how to use this plugin. Try it by cloning the repo, running `fastlane install_plugins` and `bundle exec fastlane test`.
@@ -12,6 +12,7 @@ module Fastlane
12
12
  MATCH_KEYSTORE_PATH = :MATCH_KEYSTORE_PATH
13
13
  MATCH_KEYSTORE_ALIAS_NAME = :MATCH_KEYSTORE_ALIAS_NAME
14
14
  MATCH_KEYSTORE_APK_SIGNED = :MATCH_KEYSTORE_APK_SIGNED
15
+ MATCH_KEYSTORE_AAB_SIGNED = :MATCH_KEYSTORE_AAB_SIGNED
15
16
  end
16
17
 
17
18
  class MatchKeystoreAction < Action
@@ -299,6 +300,22 @@ module Fastlane
299
300
  apk_path_signed
300
301
  end
301
302
 
303
+ def self.sign_aab(aab_path, keystore_path, key_password, alias_name, alias_password)
304
+
305
+ aab_path_signed = aab_path.gsub('.aab', '-signed.aab')
306
+ aab_path_signed = aab_path_signed.gsub('unsigned', '')
307
+ aab_path_signed = aab_path_signed.gsub('--', '-')
308
+ `rm -f '#{aab_path_signed}'`
309
+
310
+ UI.message("Signing AAB (input): #{aab_path}")
311
+ aabsigner_opts = ""
312
+ output = `jarsigner -keystore '#{keystore_path}' -storepass '#{key_password}' -keypass '#{alias_password}' -signedjar '#{aab_path_signed}' '#{aab_path}' '#{alias_name}'`
313
+ puts ""
314
+ puts output
315
+
316
+ aab_path_signed
317
+ end
318
+
302
319
  def self.resolve_dir(path)
303
320
  if !File.directory?(path)
304
321
  path = File.join(Dir.pwd, path)
@@ -322,6 +339,34 @@ module Fastlane
322
339
  data
323
340
  end
324
341
 
342
+ def self.resolve_aab_path(aab_path)
343
+
344
+ # Set default AAB path if not set:
345
+ if aab_path.to_s.strip.empty?
346
+ aab_path = '/app/build/outputs/bundle/release/'
347
+ end
348
+
349
+ if !aab_path.to_s.end_with?('.aab')
350
+
351
+ aab_path = self.resolve_dir(aab_path)
352
+
353
+ pattern = File.join(aab_path, '*.aab')
354
+ files = Dir[pattern]
355
+
356
+ for file in files
357
+ if file.to_s.end_with?('.aab') && !file.to_s.end_with?("-signed.aab")
358
+ apk_path = file
359
+ break
360
+ end
361
+ end
362
+
363
+ else
364
+ aab_path = self.resolve_file(aab_path)
365
+ end
366
+
367
+ aab_path
368
+ end
369
+
325
370
  def self.resolve_apk_path(apk_path)
326
371
 
327
372
  # Set default APK path if not set:
@@ -366,6 +411,7 @@ module Fastlane
366
411
  git_url = params[:git_url]
367
412
  package_name = params[:package_name]
368
413
  apk_path = params[:apk_path]
414
+ aab_path = params[:aab_path]
369
415
  existing_keystore = params[:existing_keystore]
370
416
  match_secret = params[:match_secret]
371
417
  override_keystore = params[:override_keystore]
@@ -575,13 +621,13 @@ module Fastlane
575
621
  File.delete(properties_path)
576
622
  end
577
623
 
578
- # Resolve path to the APK to sign:
579
- output_signed_apk = ''
580
- apk_path = self.resolve_apk_path(apk_path)
581
-
582
624
  # Sign APK:
583
- if File.file?(apk_path)
625
+ if apk_path && File.file?(apk_path)
584
626
  UI.message("APK to sign: " + apk_path)
627
+
628
+ # Resolve path to the APK to sign:
629
+ output_signed_apk = ''
630
+ apk_path = self.resolve_apk_path(apk_path)
585
631
 
586
632
  if File.file?(keystore_path)
587
633
 
@@ -598,16 +644,44 @@ module Fastlane
598
644
  )
599
645
  puts ''
600
646
  end
601
- else
602
- UI.message("No APK file found at: #{apk_path}")
603
- end
604
647
 
605
- # Prepare contect shared values for next lanes:
606
- Actions.lane_context[SharedValues::MATCH_KEYSTORE_PATH] = keystore_path
607
- Actions.lane_context[SharedValues::MATCH_KEYSTORE_ALIAS_NAME] = alias_name
608
- Actions.lane_context[SharedValues::MATCH_KEYSTORE_APK_SIGNED] = output_signed_apk
648
+ # Prepare contect shared values for next lanes:
649
+ Actions.lane_context[SharedValues::MATCH_KEYSTORE_PATH] = keystore_path
650
+ Actions.lane_context[SharedValues::MATCH_KEYSTORE_ALIAS_NAME] = alias_name
651
+ Actions.lane_context[SharedValues::MATCH_KEYSTORE_APK_SIGNED] = output_signed_apk
609
652
 
610
- output_signed_apk
653
+ output_signed_apk
654
+ # Sign AAB
655
+ elsif aab_path && File.file?(aab_path)
656
+ UI.message('AAB to sign: '+ aab_path)
657
+
658
+ # Resolve path to the AAB to sign:
659
+ output_signed_aab = ''
660
+ aab_path = self.resolve_aab_path(aab_path)
661
+
662
+ if File.file?(keystore_path)
663
+
664
+ UI.message("Signing the AAB...")
665
+ puts ''
666
+ output_signed_aab = self.sign_aab(
667
+ aab_path,
668
+ keystore_path,
669
+ key_password,
670
+ alias_name,
671
+ alias_password
672
+ )
673
+ puts ''
674
+ end
675
+
676
+ # Prepare contect shared values for next lanes:
677
+ Actions.lane_context[SharedValues::MATCH_KEYSTORE_PATH] = keystore_path
678
+ Actions.lane_context[SharedValues::MATCH_KEYSTORE_ALIAS_NAME] = alias_name
679
+ Actions.lane_context[SharedValues::MATCH_KEYSTORE_AAB_SIGNED] = output_signed_aab
680
+
681
+ output_signed_aab
682
+ else
683
+ UI.message("No APK or AAB file found")
684
+ end
611
685
  end
612
686
 
613
687
  def self.description
@@ -615,7 +689,7 @@ module Fastlane
615
689
  end
616
690
 
617
691
  def self.authors
618
- ["Christopher NEY"]
692
+ ["Christopher NEY", "Simon Scherzinger"]
619
693
  end
620
694
 
621
695
  def self.return_value
@@ -626,7 +700,8 @@ module Fastlane
626
700
  [
627
701
  ['MATCH_KEYSTORE_PATH', 'File path of the Keystore fot the App.'],
628
702
  ['MATCH_KEYSTORE_ALIAS_NAME', 'Keystore Alias Name.'],
629
- ['MATCH_KEYSTORE_APK_SIGNED', 'Path of the signed APK.']
703
+ ['MATCH_KEYSTORE_APK_SIGNED', 'Path of the signed APK.'],
704
+ ['MATCH_KEYSTORE_AAB_SIGNED', 'Path of the signed AAB.']
630
705
  ]
631
706
  end
632
707
 
@@ -652,6 +727,11 @@ module Fastlane
652
727
  description: "Path of the APK file to sign",
653
728
  optional: true,
654
729
  type: String),
730
+ FastlaneCore::ConfigItem.new(key: :aab_path,
731
+ env_name: "MATCH_KEYSTORE_AAB_PATH",
732
+ description: "Path of the AAB file to sign",
733
+ optional: true,
734
+ type: String),
655
735
  FastlaneCore::ConfigItem.new(key: :match_secret,
656
736
  env_name: "MATCH_KEYSTORE_SECRET",
657
737
  description: "Secret to decrypt keystore.properties file (CI)",
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module MatchKeystore
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-match_keystore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher NEY
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-17 00:00:00.000000000 Z
11
+ date: 2021-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
167
  - !ruby/object:Gem::Version
168
168
  version: '0'
169
169
  requirements: []
170
- rubygems_version: 3.2.6
170
+ rubygems_version: 3.2.17
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: Easily sync your Android keystores across your team