-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathupload-archive.sh
executable file
·75 lines (55 loc) · 2.56 KB
/
upload-archive.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
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
LOG="/tmp/bugsplat-upload.log"
if [ ! -f "${HOME}/.bugsplat.conf" ]
then
echo "Missing bugsplat config file: ~/.bugsplat.conf" >> $LOG 2>&1
exit
fi
source "${HOME}/.bugsplat.conf"
if [ -z "${BUGSPLAT_USER}" ]
then
echo "BUGSPLAT_USER must be set in ~/.bugsplat.conf" >> $LOG 2>&1
exit
fi
if [ -z "${BUGSPLAT_PASS}" ]
then
echo "BUGSPLAT_PASS must be set in ~/.bugsplat.conf" >> $LOG 2>&1
exit
fi
DATE=$( /bin/date +"%Y-%m-%d" )
ARCHIVE_DIR="${HOME}/Library/Developer/Xcode/Archives/${DATE}"
ARCHIVE=$( /bin/ls -t "${ARCHIVE_DIR}" | /usr/bin/grep xcarchive | /usr/bin/sed -n 1p )
echo "Archive: ${ARCHIVE}" > $LOG 2>&1
APP="${ARCHIVE_DIR}/${ARCHIVE}/Products/Applications/${PRODUCT_NAME}.app"
APP_MARKETING_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${APP}/Contents/Info.plist")
APP_BUNDLE_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${APP}/Contents/Info.plist")
echo "App marketing version: ${APP_MARKETING_VERSION}" >> $LOG 2>&1
echo "App bundle version: ${APP_BUNDLE_VERSION}" >> $LOG 2>&1
APP_VERSION="${APP_MARKETING_VERSION}"
if [ -n "${APP_BUNDLE_VERSION}" ]
then
APP_VERSION="${APP_VERSION} (${APP_BUNDLE_VERSION})"
fi
BUGSPLAT_SERVER_URL=$(/usr/libexec/PlistBuddy -c "Print BugsplatServerURL" "${APP}/Contents/Info.plist")
BUGSPLAT_SERVER_URL=${BUGSPLAT_SERVER_URL%/}
UPLOAD_URL="${BUGSPLAT_SERVER_URL}/post/plCrashReporter/symbol/"
echo "App version: ${APP_VERSION}" >> $LOG 2>&1
echo "Zipping ${ARCHIVE}" >> $LOG 2>&1
/bin/rm "/tmp/${PRODUCT_NAME}.xcarchive.zip"
cd "${ARCHIVE_DIR}/${ARCHIVE}"
/usr/bin/zip -r "/tmp/${PRODUCT_NAME}.xcarchive.zip" *
cd -
UUID_CMD_OUT=$(xcrun dwarfdump --uuid "${APP}/Contents/MacOS/${PRODUCT_NAME}")
UUID_CMD_OUT=$([[ "${UUID_CMD_OUT}" =~ ^(UUID: )([0-9a-zA-Z\-]+) ]] && echo ${BASH_REMATCH[2]})
echo "UUID found: ${UUID_CMD_OUT}" > $LOG 2>&1
echo "Signing into bugsplat and storing session cookie for use in upload" >> $LOG 2>&1
COOKIEPATH="/tmp/bugsplat-cookie.txt"
LOGIN_URL="${BUGSPLAT_SERVER_URL}/browse/login.php"
echo "Login URL: ${LOGIN_URL}"
rm "${COOKIEPATH}"
curl -b "${COOKIEPATH}" -c "${COOKIEPATH}" --data-urlencode "currusername=${BUGSPLAT_USER}" --data-urlencode "currpasswd=${BUGSPLAT_PASS}" "${LOGIN_URL}"
echo "Uploading /tmp/${PRODUCT_NAME}.xcarchive.zip to ${UPLOAD_URL}" >> $LOG 2>&1
curl -i -b "${COOKIEPATH}" -c "${COOKIEPATH}" -F filedata=@"/tmp/${PRODUCT_NAME}.xcarchive.zip" -F appName="${PRODUCT_NAME}" -F appVer="${APP_VERSION}" -F buildId="${UUID_CMD_OUT}" $UPLOAD_URL >> $LOG 2>&1