Skip to content

Commit d5cd729

Browse files
author
Rynaard Burger
committed
Add bundletool_generate_signed_apk action
1 parent 805674d commit d5cd729

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
module Fastlane
2+
module Actions
3+
class BundletoolGenerateUniversalSignedApkAction < Action
4+
def self.run(params)
5+
aab_path = params[:aab_path]
6+
apk_output_path = params[:apk_output_path]
7+
keystore_path = params[:keystore_path]
8+
keystore_password = params[:keystore_password]
9+
keystore_key_alias = params[:keystore_key_alias]
10+
signing_key_password = params[:signing_key_password]
11+
12+
begin
13+
sh('command -v bundletool > /dev/null')
14+
rescue StandardError
15+
UI.user_error!('bundletool is not installed. Please install it using the instructions at https://developer.android.com/studio/command-line/bundletool')
16+
raise
17+
end
18+
19+
sh('bundletool', 'build-apks',
20+
'--mode', 'universal',
21+
'--bundle', aab_path,
22+
'--output-format', 'DIRECTORY',
23+
'--output', apk_output_path,
24+
'--ks', keystore_path,
25+
'--ks-pass', keystore_password,
26+
'--ks-key-alias', keystore_key_alias,
27+
'--key-pass', signing_key_password)
28+
end
29+
30+
#####################################################
31+
# @!group Documentation
32+
#####################################################
33+
34+
def self.description
35+
'Generates a signed universal APK from the specified AAB'
36+
end
37+
38+
def self.details
39+
'Generates a signed universal APK from the specified AAB'
40+
end
41+
42+
def self.available_options
43+
[
44+
FastlaneCore::ConfigItem.new(
45+
key: :aab_path,
46+
env_name: 'BUNDLETOOL_AAB_PATH',
47+
description: 'The path to the AAB file',
48+
type: String,
49+
optional: false,
50+
default_value: nil
51+
),
52+
FastlaneCore::ConfigItem.new(
53+
key: :apk_output_path,
54+
env_name: 'BUNDLETOOL_APK_OUTPUT_PATH',
55+
description: 'The path to the output directory where the APK will be generated',
56+
type: String,
57+
optional: false,
58+
default_value: nil
59+
),
60+
FastlaneCore::ConfigItem.new(
61+
key: :keystore_path,
62+
env_name: 'BUNDLETOOL_KEYSTORE_PATH',
63+
description: 'The path to the keystore file',
64+
type: String,
65+
optional: false,
66+
default_value: nil
67+
),
68+
FastlaneCore::ConfigItem.new(
69+
key: :keystore_password,
70+
env_name: 'BUNDLETOOL_KEYSTORE_PASSWORD',
71+
description: 'The password for the keystore',
72+
type: String,
73+
optional: false,
74+
default_value: nil
75+
),
76+
FastlaneCore::ConfigItem.new(
77+
key: :keystore_key_alias,
78+
env_name: 'BUNDLETOOL_KEYSTORE_KEY_ALIAS',
79+
description: 'The alias of the key in the keystore',
80+
type: String,
81+
optional: false,
82+
default_value: nil
83+
),
84+
FastlaneCore::ConfigItem.new(
85+
key: :signing_key_password,
86+
env_name: 'BUNDLETOOL_SIGNING_KEY_PASSWORD',
87+
description: 'The password for the signing key',
88+
type: String,
89+
optional: false,
90+
default_value: nil
91+
),
92+
]
93+
end
94+
95+
def self.authors
96+
['Automattic']
97+
end
98+
99+
def self.is_supported?(platform)
100+
true
101+
end
102+
end
103+
end
104+
end

0 commit comments

Comments
 (0)