forked from mobiledevpro/Android-Kotlin-MVVM-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathci-deploy-dropbox.sh
executable file
·47 lines (35 loc) · 1.38 KB
/
ci-deploy-dropbox.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
#! /bin/sh
#Token from Dropbox Settings.
#DROPBOX_TOKEN="add this token to Circle CI Environment Variables in the project settings"
APK_FILES="./app/build/outputs/bundle/*/*-release.aab"
MAPPING_FILES="./app/build/outputs/mapping/*/mapping.txt"
for FILE in $APK_FILES; do
#check file is exist and not empty
if [ -f "${FILE}" ] && [ -s "${FILE}" ]; then
echo "Found AAB: ${FILE}"
FILE_NAME=$(basename "${FILE}")
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer ${DROPBOX_TOKEN}" \
--header "Dropbox-API-Arg: {\"path\": \"\/${FILE_NAME}\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary @"${FILE}"
else
echo "File ${FILE} is empty"
exit 1
fi
done
for TXT in $MAPPING_FILES; do
#check file is exist and not empty
if [ -f "${TXT}" ] && [ -s "${TXT}" ]; then
echo "Found mapping: ${TXT}"
TXT_NAME=$(basename "${TXT}")
curl -X POST https://content.dropboxapi.com/2/files/upload \
--header "Authorization: Bearer ${DROPBOX_TOKEN}" \
--header "Dropbox-API-Arg: {\"path\": \"\/${TXT_NAME}\",\"mode\": \"overwrite\",\"autorename\": true,\"mute\": false}" \
--header "Content-Type: application/octet-stream" \
--data-binary @"${FILE}"
else
echo "File ${TXT} is empty"
exit 1
fi
done