fastlane-plugin-bundletool 1.0.7 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -2
- data/lib/fastlane/plugin/bundletool/actions/bundletool_action.rb +60 -22
- data/lib/fastlane/plugin/bundletool/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fb3b3676492fd3f6a4bfc64426a28937f6c92bf98024ccacf761169d2443383
|
4
|
+
data.tar.gz: 861566dc3312e4cfe2199f773f0ae10a33a8e43bb096d5a0a0b194595d97c427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b51d6b7495b427fb35c3c6f8c429299da981d7eae09847577af154735cde54d99ea1dda1e5eb3d4c12a0cbf27fabeaede25299a62696778ecdaa2fc52cf20dc
|
7
|
+
data.tar.gz: a06d8c3ab1aaf481295abe63a31c2afaa9fcdfce0eef51de05f8c5a246502883660ebd47a02d84ec418d488b96852d3cd1e5fca4f8ac023fcbcc279f2106ff56
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ fastlane add_plugin bundletool
|
|
13
13
|
or in your Pluginfile under fastlane folder write the following line and run `bundle install`.
|
14
14
|
|
15
15
|
```
|
16
|
-
gem 'fastlane-plugin-bundletool', '1.0.
|
16
|
+
gem 'fastlane-plugin-bundletool', '1.0.8'
|
17
17
|
```
|
18
18
|
|
19
19
|
## About bundletool
|
@@ -37,12 +37,31 @@ bundletool(
|
|
37
37
|
bundletool_version: '1.10.0', # For searching a specific version of bundletool visit https://github.com/google/bundletool/releases
|
38
38
|
aab_path: aab_path,
|
39
39
|
apk_output_path: apk_output_path,
|
40
|
-
verbose: true
|
40
|
+
verbose: true,
|
41
|
+
cache_path: cache_path
|
41
42
|
)
|
42
43
|
```
|
43
44
|
|
44
45
|
This will output the universal `.apk` in the output path you set.
|
45
46
|
|
47
|
+
## Options
|
48
|
+
|
49
|
+
| Key | Description | Env Var(s) | Default |
|
50
|
+
|-----------------------|---------------------------------------------------------|---------------------------------|---------|
|
51
|
+
| ks_path | Path to .jks file | FL_BUNDLETOOL_KEYSTORE_FILE | |
|
52
|
+
| ks_password | .jks password | FL_BUNDLETOOL_KEYSTORE_PASSWORD | |
|
53
|
+
| ks_key_alias | Alias for jks | FL_BUNDLETOOL_KEY_ALIAS | |
|
54
|
+
| ks_key_alias_password | Alias password for .jks | FL_BUNDLETOOL_KEY_PASSWORD | |
|
55
|
+
| bundletool_version | Version of bundletool to use, by default 0.11.0 will | FL_BUNDLETOOL_VERSION | 0.11.0 |
|
56
|
+
| | be used | | |
|
57
|
+
| download_url | Url to download bundletool from, should point to a jar | FL_BUNDLETOOL_DOWNLOAD_URL | |
|
58
|
+
| | file | | |
|
59
|
+
| aab_path | Path where the aab file is | FL_BUNDLETOOL_AAB_PATH | |
|
60
|
+
| apk_output_path | Path where the apk file is going to be placed | FL_BUNDLETOOL_APK_OUTPUT_PATH | . |
|
61
|
+
| verbose | Show every messages of the action | FL_BUNDLETOOL_VERBOSE | false |
|
62
|
+
| cache_path | Cache downloaded bundletool binary into the cache path | FL_BUNDLETOOL_CACHE_PATH | |
|
63
|
+
|-----------------------|---------------------------------------------------------|---------------------------------|---------|
|
64
|
+
|
46
65
|
## Use case
|
47
66
|
|
48
67
|
Here you can find a post I did explaining why I have to create this action.
|
@@ -23,12 +23,33 @@ module Fastlane
|
|
23
23
|
download_url = params[:download_url]
|
24
24
|
aab_path = params[:aab_path]
|
25
25
|
output_path = params[:apk_output_path] || '.'
|
26
|
+
cache_path = params[:cache_path]
|
26
27
|
|
27
28
|
return unless validate_aab!(aab_path)
|
28
29
|
|
29
|
-
|
30
|
+
if(cache_path.nil?)
|
31
|
+
installation_path = @bundletool_temp_path
|
32
|
+
else
|
33
|
+
installation_path = Pathname.new(File.expand_path(cache_path)).to_s
|
34
|
+
end
|
35
|
+
|
36
|
+
unless(Dir.exist?(installation_path))
|
37
|
+
Dir.mkdir(installation_path)
|
38
|
+
end
|
39
|
+
|
40
|
+
unless(Dir.exist?(@bundletool_temp_path))
|
41
|
+
Dir.mkdir(@bundletool_temp_path)
|
42
|
+
end
|
30
43
|
|
31
|
-
|
44
|
+
unless download_url.nil?
|
45
|
+
bundletool_filename = "bundletool_#{id = Digest::SHA256.hexdigest(download_url)}.jar"
|
46
|
+
else
|
47
|
+
bundletool_filename = "bundletool_#{bundletool_version}.jar"
|
48
|
+
end
|
49
|
+
|
50
|
+
return unless download_bundletool(bundletool_version, download_url, bundletool_filename, installation_path)
|
51
|
+
|
52
|
+
extract_universal_apk_from(aab_path, output_path, keystore_info, bundletool_filename, installation_path)
|
32
53
|
end
|
33
54
|
|
34
55
|
def self.validate_aab!(aab_path)
|
@@ -41,29 +62,24 @@ module Fastlane
|
|
41
62
|
return true
|
42
63
|
end
|
43
64
|
|
44
|
-
def self.download_bundletool(version, download_url)
|
45
|
-
Dir.mkdir "#{@project_root}/bundletool_temp"
|
46
|
-
|
65
|
+
def self.download_bundletool(version, download_url, bundletool_filename, cache_path)
|
47
66
|
unless download_url.nil?
|
48
|
-
|
49
|
-
puts_message("Downloading bundletool from #{download_url}")
|
50
|
-
download_and_write_bundletool(download_url)
|
67
|
+
download_and_write_bundletool(download_url, bundletool_filename, cache_path)
|
51
68
|
else
|
52
|
-
|
53
|
-
download_and_write_bundletool(
|
54
|
-
end
|
55
|
-
|
56
|
-
true
|
69
|
+
bundletool_url = "https://github.com/google/bundletool/releases/download/#{version}/bundletool-all-#{version}.jar"
|
70
|
+
download_and_write_bundletool(bundletool_url, bundletool_filename, cache_path)
|
71
|
+
end
|
72
|
+
return true
|
57
73
|
rescue OpenURI::HTTPError => e
|
58
74
|
clean_temp!
|
59
75
|
puts_error!("Something went wrong when downloading bundletool version #{version}" + ". \nError message\n #{e.message}")
|
60
|
-
false
|
76
|
+
return false
|
61
77
|
end
|
62
78
|
|
63
|
-
def self.extract_universal_apk_from(aab_path, apk_output_path, keystore_info)
|
79
|
+
def self.extract_universal_apk_from(aab_path, apk_output_path, keystore_info, bundletool_filename, installation_path)
|
64
80
|
aab_absolute_path = Pathname.new(File.expand_path(aab_path)).to_s
|
65
81
|
apk_output_absolute_path = Pathname.new(File.expand_path(apk_output_path)).to_s
|
66
|
-
output_path = run_bundletool!(aab_absolute_path, keystore_info)
|
82
|
+
output_path = run_bundletool!(aab_absolute_path, keystore_info, bundletool_filename, installation_path)
|
67
83
|
prepare_apk!(output_path, apk_output_absolute_path)
|
68
84
|
rescue StandardError => e
|
69
85
|
puts_error!("Bundletool could not extract universal apk from aab at #{aab_absolute_path}. \nError message\n #{e.message}")
|
@@ -71,7 +87,7 @@ module Fastlane
|
|
71
87
|
clean_temp!
|
72
88
|
end
|
73
89
|
|
74
|
-
def self.run_bundletool!(aab_path, keystore_info)
|
90
|
+
def self.run_bundletool!(aab_path, keystore_info, bundletool_filename, installation_path)
|
75
91
|
puts_message("Extracting apk from #{aab_path}...")
|
76
92
|
output_path = "#{@bundletool_temp_path}/output.apks"
|
77
93
|
keystore_params = ''
|
@@ -80,7 +96,7 @@ module Fastlane
|
|
80
96
|
keystore_params = "--ks='#{keystore_info[:keystore_path]}' --ks-pass='pass:#{keystore_info[:keystore_password]}' --ks-key-alias='#{keystore_info[:alias]}' --key-pass='pass:#{keystore_info[:alias_password]}'"
|
81
97
|
end
|
82
98
|
|
83
|
-
cmd = "java -jar #{
|
99
|
+
cmd = "java -jar #{installation_path}/#{bundletool_filename} build-apks --bundle=\"#{aab_path}\" --output=\"#{output_path}\" --mode=universal #{keystore_params}"
|
84
100
|
|
85
101
|
Open3.popen3(cmd) do |_, _, stderr, wait_thr|
|
86
102
|
exit_status = wait_thr.value
|
@@ -142,30 +158,37 @@ module Fastlane
|
|
142
158
|
def self.available_options
|
143
159
|
[
|
144
160
|
FastlaneCore::ConfigItem.new(key: :ks_path,
|
161
|
+
env_name: 'FL_BUNDLETOOL_KEYSTORE_FILE',
|
145
162
|
description: 'Path to .jks file',
|
146
163
|
is_string: true,
|
147
164
|
optional: true),
|
148
165
|
FastlaneCore::ConfigItem.new(key: :ks_password,
|
166
|
+
env_name: 'FL_BUNDLETOOL_KEYSTORE_PASSWORD',
|
149
167
|
description: '.jks password',
|
150
168
|
is_string: true,
|
151
169
|
optional: true),
|
152
170
|
FastlaneCore::ConfigItem.new(key: :ks_key_alias,
|
171
|
+
env_name: 'FL_BUNDLETOOL_KEY_ALIAS',
|
153
172
|
description: 'Alias for jks',
|
154
173
|
is_string: true,
|
155
174
|
optional: true),
|
156
175
|
FastlaneCore::ConfigItem.new(key: :ks_key_alias_password,
|
176
|
+
env_name: 'FL_BUNDLETOOL_KEY_PASSWORD',
|
157
177
|
description: 'Alias password for .jks',
|
158
178
|
is_string: true,
|
159
179
|
optional: true),
|
160
180
|
FastlaneCore::ConfigItem.new(key: :bundletool_version,
|
181
|
+
env_name: 'FL_BUNDLETOOL_VERSION',
|
161
182
|
description: 'Version of bundletool to use, by default 0.11.0 will be used',
|
162
183
|
is_string: true,
|
163
184
|
default_value: '0.11.0'),
|
164
185
|
FastlaneCore::ConfigItem.new(key: :download_url,
|
186
|
+
env_name: 'FL_BUNDLETOOL_DOWNLOAD_URL',
|
165
187
|
description: 'Url to download bundletool from, should point to a jar file',
|
166
188
|
is_string: true,
|
167
189
|
optional: true),
|
168
190
|
FastlaneCore::ConfigItem.new(key: :aab_path,
|
191
|
+
env_name: 'FL_BUNDLETOOL_AAB_PATH',
|
169
192
|
description: 'Path where the aab file is',
|
170
193
|
is_string: true,
|
171
194
|
optional: false,
|
@@ -175,17 +198,23 @@ module Fastlane
|
|
175
198
|
end
|
176
199
|
end),
|
177
200
|
FastlaneCore::ConfigItem.new(key: :apk_output_path,
|
201
|
+
env_name: 'FL_BUNDLETOOL_APK_OUTPUT_PATH',
|
178
202
|
description: 'Path where the apk file is going to be placed',
|
179
203
|
is_string: true,
|
180
204
|
optional: true,
|
181
205
|
default_value: '.'),
|
182
206
|
FastlaneCore::ConfigItem.new(key: :verbose,
|
207
|
+
env_name: 'FL_BUNDLETOOL_VERBOSE',
|
183
208
|
description: 'Show every messages of the action',
|
184
209
|
is_string: false,
|
185
210
|
type: Boolean,
|
186
211
|
optional: true,
|
187
|
-
default_value: false)
|
188
|
-
|
212
|
+
default_value: false),
|
213
|
+
FastlaneCore::ConfigItem.new(key: :cache_path,
|
214
|
+
env_name: 'FL_BUNDLETOOL_CACHE_PATH',
|
215
|
+
description: 'Cache downloaded bundletool binary into the cache path specified',
|
216
|
+
is_string: true,
|
217
|
+
optional: true)
|
189
218
|
]
|
190
219
|
end
|
191
220
|
|
@@ -214,12 +243,21 @@ module Fastlane
|
|
214
243
|
|
215
244
|
private
|
216
245
|
|
217
|
-
def self.download_and_write_bundletool(download_url)
|
246
|
+
def self.download_and_write_bundletool(download_url, bundletool_filename, installation_path)
|
247
|
+
if(File.exist?"#{installation_path}/#{bundletool_filename}")
|
248
|
+
puts_message("Using binary cached at #{installation_path}/#{bundletool_filename}")
|
249
|
+
return
|
250
|
+
end
|
251
|
+
|
252
|
+
puts_message("Downloading bundletool from #{download_url}")
|
253
|
+
|
218
254
|
URI.open(download_url) do |bundletool|
|
219
|
-
File.open("#{
|
255
|
+
File.open("#{installation_path}/#{bundletool_filename}", 'wb') do |file|
|
220
256
|
file.write(bundletool.read)
|
221
257
|
end
|
222
258
|
end
|
259
|
+
|
260
|
+
puts_success('Downloaded bundletool')
|
223
261
|
end
|
224
262
|
end
|
225
263
|
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.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Gonzalez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02
|
11
|
+
date: 2023-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|