Skip to content

Instantly share code, notes, and snippets.

@zoul
Last active August 29, 2015 14:16
Show Gist options
  • Save zoul/37f0a16c9cda0a2ace11 to your computer and use it in GitHub Desktop.
Save zoul/37f0a16c9cda0a2ace11 to your computer and use it in GitHub Desktop.
Upload a HockeyApp version from an Xcode Continuous Integration Bot, iOS version
# Based on http://hack.swic.name/automated-xcode-6-bot-testflight-uploads/
API_TOKEN="XXX"
APP_ID="XXX"
upload() {
BASE_PATH="/Library/Developer/XcodeServer/IntegrationAssets/"
IPA="${BASE_PATH}${XCS_BOT_ID}-${XCS_BOT_NAME}/${XCS_INTEGRATION_NUMBER}/${XCS_BOT_NAME}.ipa"
ARCHIVE="${BASE_PATH}${XCS_BOT_ID}-${XCS_BOT_NAME}/${XCS_INTEGRATION_NUMBER}/Archive.xcarchive.zip"
DSYM_ZIP="/tmp/dSYM.zip"
# Remove old files 'n folders
rm /tmp/hockey_log
rm /tmp/hockey_upload
rm /tmp/hockey_uploadout
rm -rf /tmp/Archive.xcarchive
rm "${DSYM_ZIP}"
TIMEOUT=120
until [ -e "${IPA}" ]; do
echo "Waiting for ${IPA} to exist" >> /tmp/hockey_log
if [ $TIMEOUT -eq 0 ]
then
echo "Giving up on ${IPA} existence" >> /tmp/hockey_log
exit
else
TIMEOUT=$((TIMEOUT-1))
fi
sleep 1
done
# Unzip Archive to get at the juicy dSYM files
echo "Unpacking ${ARCHIVE} to /tmp/Archive.xcarchive" >> /tmp/hockey_log
unzip "${ARCHIVE}" -d /tmp >> /tmp/hockey_log
# Zip the aforementioned juicy dSYM files up for Hockey.app
echo "Packing dSYM(s) as ${DSYM_ZIP}" >> /tmp/hockey_log
pushd /tmp/Archive.xcarchive/dSYMs
zip -r "${DSYM_ZIP}" * >> /tmp/hockey_log
popd
# Get the SCM log
SCM_LOG=$(grep "\s\s\s\s\s\s\s" ${BASE_PATH}${XCS_BOT_ID}-${XCS_BOT_NAME}/${XCS_INTEGRATION_NUMBER}/sourceControl.log | sed 's/ //g')
# Upload to Hockey.app
echo "Uploading to Hockey.app" >> /tmp/hockey_log
curl -v "https://rink.hockeyapp.net/api/2/apps/${APP_ID}/app_versions/upload" \
-F status=2 \
-F notify=0 \
-F ipa=@"${IPA}" \
-F dsym=@"${DSYM_ZIP}" \
-H "X-HockeyAppToken: ${API_TOKEN}" \
-F notes="${SCM_LOG}" \
--stderr /tmp/hockey_upload -o /tmp/hockey_uploadout
# Clean up after ourselves before we leave
rm -rf /tmp/Archive.xcarchive
rm "${DSYM_ZIP}"
}
echo "Starting Hockey.app upload, check /tmp/hockey_log for status";
upload &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment