-
Notifications
You must be signed in to change notification settings - Fork 0
/
upload.sh
executable file
·64 lines (49 loc) · 1.97 KB
/
upload.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
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
if [ -z "$MAJOR_MINOR" ]; then
MAJOR_MINOR="alpha"
fi
if [ -z "$PLUGIN_APK_PATH" ]; then
PLUGIN_APK_PATH="app/build/outputs/apk/debug/app-debug.apk"
fi
if [ -z "$PLUGIN_MAPPING_PATH" ]; then
PLUGIN_MAPPING_PATH="app/build/outputs/mapping/debug/mapping.txt"
fi
if [ -z "$PLUGIN_FILENAME" ]; then
PLUGIN_FILENAME="Lawnchair"
fi
if [ -z "$PLUGIN_CHANNEL_ID" ]; then
PLUGIN_CHANNEL_ID="-1001180711841"
fi
if [ -z "$PLUGIN_MAIL_SENDER" ]; then
PLUGIN_MAIL_SENDER="Lawnchair CI \(Buildbot\)"
fi
if [ -z "$PLUGIN_MAIL_FROM" ]; then
PLUGIN_MAIL_FROM="[email protected]"
fi
# Fix dashes in MAJOR_MINOR to not break tags
MAJOR_MINOR=$(echo "${MAJOR_MINOR}" | sed -r 's/-/_/g')
# Adding body to changelog (intentional whitespace!!)
CHANGELOG=" Changelog for build ${MAJOR_MINOR}-${DRONE_BUILD_NUMBER}:
$(cat changelog.txt)"
# Preparing files to upload
cp $PLUGIN_APK_PATH ${PLUGIN_FILENAME}-${MAJOR_MINOR}_$DRONE_BUILD_NUMBER.apk
cp $PLUGIN_MAPPING_PATH proguard-${MAJOR_MINOR}_$DRONE_BUILD_NUMBER.txt
# Obtain nonce
WP_NONCE=$(curl https://www.apkmirror.com | grep -Eow "\"_wpnonce\", '([a-z0-9]+)'" | sed "s/\"_wpnonce\", '//" | sed "s/'//")
FULLNAME="Lawnchair CI (Buildbot)"
EMAIL="[email protected]"
# Date and time of upload
UPLOAD_DATE=$(date '+%Y-%m-%d at %H:%M:%S')
# Upload it to APKMirror
OUTPUT=$(curl -v \
-F fullname="$FULLNAME" \
-F email="$EMAIL" \
-F changes="$CHANGELOG" \
-F _wpnonce="$WP_NONCE" \
-F file=@"${PLUGIN_FILENAME}-${MAJOR_MINOR}_$DRONE_BUILD_NUMBER.apk" \
https://www.apkmirror.com/wp-content/plugins/UploadManager/inc/upload.php)
# Send curl output via email
sendmail.sh "$PLUGIN_MAIL_SENDER" $PLUGIN_MAIL_FROM $NOTIFY_EMAIL \
"[$DRONE_REPO_OWNER/$DRONE_REPO_NAME] Build #${DRONE_BUILD_NUMBER} uploaded to APKMirror" \
"This message is to inform that build #${DRONE_BUILD_NUMBER} has been uploaded to APKMirror on $UPLOAD_DATE with result: ${OUTPUT}" \
$MAIL_SERVER $MAIL_USER $MAIL_PASSWORD