forked from ch4vi/bitrise-step-bundle-universal-apk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
step.sh
53 lines (39 loc) · 1.44 KB
/
step.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
#set -ex
#=======================================
# Main
#=======================================
#step_path="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
temp_path=$PWD
echo "building universal apk path"
echo "Getting app bundle from ${aab_path}"
echo "Signing with ${keystore_url} key and alias ${keystore_alias}"
echo "files in deploy directory"
for filename in $(ls /bitrise/deploy/)
do
echo $filename
done;
bundletool="${temp_path}/bundletool.jar"
keystore="${temp_path}/keystore.jks"
source="https://github.com/google/bundletool/releases/download/0.8.0/bundletool-all-0.8.0.jar"
# Building
aab_output_path="${temp_path}/output/bundle"
aab_output="${aab_output_path}/app.apks"
apk_output_path="${temp_path}/output/apk"
apk_output="${apk_output_path}/universal.apk"
mkdir -p "${aab_output_path}" &
mkdir -p "${apk_output_path}" &
wait
echo "Downloading keystore"
curl -o "keystore.jks" "${keystore_url}"
echo "Downloading bundle tool"
wget -nv "${source}" --output-document="${bundletool}" &
wait
echo "Extracting bundle apks"
exec java -jar "${bundletool}" build-apks --bundle="${aab_path}" --output="${aab_output}" --mode=universal --ks=${keystore} --ks-pass=pass:"${keystore_password}" --ks-key-alias="${keystore_alias}" --key-pass=pass:"${keystore_alias_password}" &
wait
echo "APK created in ${apk_output_path}"
exec unzip ${aab_output} -d ${apk_output_path} &
wait
envman add --key BITRISE_APK_PATH --value ${apk_output}
exit 0