fastlane-plugin-bundletool 1.0.11 → 1.1.0

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: b2656e2f3d17ab99447189a43f7337906d1f84eeb4418ad25ec2f9203564764a
4
- data.tar.gz: b2ee465e8168baa2926a119059157747a51e12b9334e1c87ab116b713f96d200
3
+ metadata.gz: 86168114efe411a2131c772024c4bdecc2390f59b16718fba36d5ecf377c17ac
4
+ data.tar.gz: d4a85823a3cad1f35a443440e33467e9bc85cbe1126e987200550681b927a888
5
5
  SHA512:
6
- metadata.gz: d2680c1e5c950a3b222c6de916ca7b9cba00cb963814fa09e3c8bfd5854708a440f7d83e73345f082ab6394f7f9a2a131750149571aa8d2101ce5fb1abe4069f
7
- data.tar.gz: 446ec9ecd3775d0c8f94b9287facba2e999b6b3471eeb61ecf230f8b248b25aa45b640cfb8f3db4ad6afa0cd78ebaca5ca868463b42ced328bd928e793f9595a
6
+ metadata.gz: 284a3920bb14be5e26d51d132571cc993b2ee7576d3ddc08e2f490a70dc555b61cea0926f6ce244bbabf18eec34663200be25bdfa017e05ad414a17991206a87
7
+ data.tar.gz: 2067707f374e46626374787a95432e8a352a31701a53bb7cb3815325a404b3ef6c4148f61091d3f9d0f4de1d45a8f79ba2ff85c7f186fe4d8565a13e99298891
data/README.md CHANGED
@@ -22,7 +22,7 @@ gem 'fastlane-plugin-bundletool'
22
22
 
23
23
  https://developer.android.com/studio/command-line/bundletool
24
24
 
25
- The motivation of this plugin is to extract an universal `.apk` file from an [.aab](https://fileinfo.com/extension/aab) file. Since we cannot distribute aab files, it's great that we can extract from the very same binary a file that we can distribute internally.
25
+ The motivation of this plugin is to extract an universal `.apk` or split `.apks` from an [.aab](https://fileinfo.com/extension/aab) file. Since we cannot distribute aab files, it's great that we can extract from the very same binary a file that we can distribute internally.
26
26
 
27
27
  ## Usage
28
28
 
@@ -38,7 +38,8 @@ bundletool(
38
38
  aab_path: aab_path,
39
39
  apk_output_path: apk_output_path,
40
40
  verbose: true,
41
- cache_path: cache_path
41
+ cache_path: cache_path,
42
+ universal_apk: true
42
43
  )
43
44
  ```
44
45
 
@@ -60,6 +61,7 @@ This will output the universal `.apk` in the output path you set.
60
61
  | apk_output_path | Path where the apk file is going to be placed | FL_BUNDLETOOL_APK_OUTPUT_PATH | . |
61
62
  | verbose | Show every messages of the action | FL_BUNDLETOOL_VERBOSE | false |
62
63
  | cache_path | Cache downloaded bundletool binary into the cache path | FL_BUNDLETOOL_CACHE_PATH | |
64
+ | universal_apk | Create universal APK (true) or split APKs (false) | FL_BUNDLETOOL_UNIVERSAL_APK | true |
63
65
  |-----------------------|---------------------------------------------------------|---------------------------------|---------|
64
66
 
65
67
  ## Use case
@@ -25,6 +25,7 @@ module Fastlane
25
25
  aab_path = params[:aab_path]
26
26
  output_path = params[:apk_output_path] || '.'
27
27
  cache_path = params[:cache_path]
28
+ universal_apk = params[:universal_apk]
28
29
 
29
30
  return unless validate_aab!(aab_path)
30
31
 
@@ -50,7 +51,7 @@ module Fastlane
50
51
 
51
52
  return unless download_bundletool(bundletool_version, download_url, bundletool_filename, installation_path)
52
53
 
53
- extract_universal_apk_from(aab_path, output_path, keystore_info, bundletool_filename, installation_path)
54
+ extract_apk_from(aab_path, output_path, keystore_info, bundletool_filename, installation_path, universal_apk)
54
55
  end
55
56
 
56
57
  def self.validate_aab!(aab_path)
@@ -77,18 +78,18 @@ module Fastlane
77
78
  return false
78
79
  end
79
80
 
80
- def self.extract_universal_apk_from(aab_path, apk_output_path, keystore_info, bundletool_filename, installation_path)
81
+ def self.extract_apk_from(aab_path, apk_output_path, keystore_info, bundletool_filename, installation_path, universal_apk)
81
82
  aab_absolute_path = Pathname.new(File.expand_path(aab_path)).to_s
82
83
  apk_output_absolute_path = Pathname.new(File.expand_path(apk_output_path)).to_s
83
- output_path = run_bundletool!(aab_absolute_path, keystore_info, bundletool_filename, installation_path)
84
- prepare_apk!(output_path, apk_output_absolute_path)
84
+ output_path = run_bundletool!(aab_absolute_path, keystore_info, bundletool_filename, installation_path, universal_apk)
85
+ prepare_apk!(output_path, apk_output_absolute_path, universal_apk)
85
86
  rescue StandardError => e
86
87
  puts_error!("Bundletool could not extract universal apk from aab at #{aab_absolute_path}. \nError message\n #{e.message}")
87
88
  ensure
88
89
  clean_temp!
89
90
  end
90
91
 
91
- def self.run_bundletool!(aab_path, keystore_info, bundletool_filename, installation_path)
92
+ def self.run_bundletool!(aab_path, keystore_info, bundletool_filename, installation_path, universal_apk)
92
93
  puts_message("Extracting apk from #{aab_path}...")
93
94
  output_path = "#{@bundletool_temp_path}/output.apks"
94
95
  keystore_params = ''
@@ -97,10 +98,12 @@ module Fastlane
97
98
  key_alias_password = Shellwords.shellescape("pass:#{keystore_info[:alias_password]}")
98
99
  key_store_password = Shellwords.shellescape("pass:#{keystore_info[:keystore_password]}")
99
100
  key_alias = Shellwords.shellescape(keystore_info[:alias])
100
- keystore_params = "--ks=#{keystore_info[:keystore_path]} --ks-pass=#{key_store_password} --ks-key-alias=#{key_alias} --key-pass=#{key_alias_password}"
101
+ keystore_params = "--ks='#{keystore_info[:keystore_path]}' --ks-pass=#{key_store_password} --ks-key-alias=#{key_alias} --key-pass=#{key_alias_password}"
101
102
  end
102
103
 
103
- cmd = "java -jar #{installation_path}/#{bundletool_filename} build-apks --bundle=\"#{aab_path}\" --output=\"#{output_path}\" --mode=universal #{keystore_params}"
104
+ universal_apk_param = universal_apk == true ? "--mode=universal" : ""
105
+
106
+ cmd = "java -jar #{installation_path}/#{bundletool_filename} build-apks --bundle=\"#{aab_path}\" --output=\"#{output_path}\" #{universal_apk_param} #{keystore_params}"
104
107
 
105
108
  Open3.popen3(cmd) do |_, _, stderr, wait_thr|
106
109
  exit_status = wait_thr.value
@@ -110,7 +113,7 @@ module Fastlane
110
113
  output_path
111
114
  end
112
115
 
113
- def self.prepare_apk!(output_path, target_path)
116
+ def self.prepare_apk!(output_path, target_path, universal_apk)
114
117
  puts_message("Preparing apk to #{target_path}...")
115
118
  if File.file?(target_path)
116
119
  puts_important("Apk at path #{target_path} exists. Replacing it.")
@@ -121,9 +124,14 @@ module Fastlane
121
124
  FileUtils.mkdir_p target_dir_name
122
125
  end
123
126
 
124
- cmd = "mv \"#{output_path}\" \"#{@bundletool_temp_path}/output.zip\" &&"\
125
- "unzip \"#{@bundletool_temp_path}/output.zip\" -d \"#{@bundletool_temp_path}\" &&"\
126
- "mv \"#{@bundletool_temp_path}/universal.apk\" \"#{target_path}\""
127
+ cmd = ''
128
+ if universal_apk == true
129
+ cmd = "mv \"#{output_path}\" \"#{@bundletool_temp_path}/output.zip\" &&"\
130
+ "unzip \"#{@bundletool_temp_path}/output.zip\" -d \"#{@bundletool_temp_path}\" &&"\
131
+ "mv \"#{@bundletool_temp_path}/universal.apk\" \"#{target_path}\""
132
+ else
133
+ cmd = "mv \"#{output_path}\" \"#{target_path}\""
134
+ end
127
135
 
128
136
  Open3.popen3(cmd) do |_, _, stderr, wait_thr|
129
137
  exit_status = wait_thr.value
@@ -220,7 +228,14 @@ module Fastlane
220
228
  env_name: 'FL_BUNDLETOOL_CACHE_PATH',
221
229
  description: 'Cache downloaded bundletool binary into the cache path specified',
222
230
  is_string: true,
223
- optional: true)
231
+ optional: true),
232
+ FastlaneCore::ConfigItem.new(key: :universal_apk,
233
+ env_name: 'FL_BUNDLETOOL_UNIVERSAL_APK',
234
+ description: 'Create universal APK (true) or split APKs (false)',
235
+ is_string: false,
236
+ type: Boolean,
237
+ optional: true,
238
+ default_value: true)
224
239
  ]
225
240
  end
226
241
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Bundletool
3
- VERSION = "1.0.11"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-bundletool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.11
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Gonzalez
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-23 00:00:00.000000000 Z
11
+ date: 2025-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -150,7 +150,7 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: 0.2.0
153
- description:
153
+ description:
154
154
  email: gonzalez.martin90@gmail.com
155
155
  executables: []
156
156
  extensions: []
@@ -167,7 +167,7 @@ homepage: https://github.com/MartinGonzalez/fastlane-plugin-bundletool
167
167
  licenses:
168
168
  - MIT
169
169
  metadata: {}
170
- post_install_message:
170
+ post_install_message:
171
171
  rdoc_options: []
172
172
  require_paths:
173
173
  - lib
@@ -183,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  version: '0'
184
184
  requirements: []
185
185
  rubygems_version: 3.2.3
186
- signing_key:
186
+ signing_key:
187
187
  specification_version: 4
188
188
  summary: Extracts a universal apk from an .aab file
189
189
  test_files: []