Created
July 16, 2012 11:37
-
-
Save diederich/3122244 to your computer and use it in GitHub Desktop.
Xcode::Archive::Post-Action HockeyApp upload
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
##### | |
# Meant to be used as an Archive Post-Action script run from within Xcode | |
# | |
# basically there are 2 modes: Interactive and Automated Jenkins Mode. | |
# Interactive is the one that's used when you're doing the Archive. Once | |
# the Archive is done, HockeyApp pops up and asks what to do with the | |
# Archive. | |
# In Jenkins Mode, there's some more stuff to do. See below for details. | |
# | |
# The mode is chosen from an env-variable that is set (or not) called | |
# AUTOMATED_JENKINS_BUILD. | |
# | |
# ToDos: | |
# * figure out a way to mark this build as failed (e.g. if upload fails) | |
# | |
##### | |
if [ -n "$AUTOMATED_JENKINS_BUILD" ]; then | |
if [ -n "$WORKSPACE" ]; then | |
TARGET_DIRECTORY="$WORKSPACE/Artifacts" | |
mkdir -p "$TARGET_DIRECTORY" | |
#copy the full xcarchive thingy (e.g. to move it to a different Xcode.app) | |
cp -r "${ARCHIVE_PATH}" "$TARGET_DIRECTORY/" | |
echo "copied ${ARCHIVE_PATH} to $WORKSPACE" | |
#zip up the dSYMs for HockeyApp upload | |
ZIPPED_DSYM_OUTPUT_FILE_PATH="$TARGET_DIRECTORY/$DWARF_DSYM_FILE_NAME.zip" | |
cd "$ARCHIVE_DSYMS_PATH" | |
zip -r "$ZIPPED_DSYM_OUTPUT_FILE_PATH" "$DWARF_DSYM_FILE_NAME" | |
echo "zipped dSYMS to $ZIPPED_DSYM_OUTPUT_FILE_PATH" | |
#create the IPA | |
IPA_INPUT_BUNDLE_PATH="$ARCHIVE_PRODUCTS_PATH/Applications/$WRAPPER_NAME" | |
IPA_OUTPUT_PATH="$TARGET_DIRECTORY/$PRODUCT_NAME.ipa" | |
/usr/bin/xcrun -sdk iphoneos PackageApplication "$IPA_INPUT_BUNDLE_PATH" -o "$IPA_OUTPUT_PATH" | |
echo "created IPA at $IPA_OUTPUT_PATH" | |
#now upload to HockeyApp | |
HOCKEYAPP_STATUS=1 #don't allow download for now | |
HOCKEYAPP_NOTIFY=0 #don't notify for now | |
if [ -n "$HOCKEYAPP_CREDENTIALS" ]; then | |
RETVAL=`curl \ | |
--silent --output /dev/null --write-out %{http_code} \ | |
-F "status=$HOCKEYAPP_STATUS" \ | |
-F "notify=$HOCKEYAPP_NOTIFY" \ | |
-F "ipa=@$IPA_OUTPUT_PATH" \ | |
-F "dsym=@$ZIPPED_DSYM_OUTPUT_FILE_PATH" \ | |
-H "X-HockeyAppToken: $HOCKEYAPP_CREDENTIALS" \ | |
https://rink.hockeyapp.netdeimudda/api/2/apps` | |
if [ "$RETVAL" = "201" ]; then | |
echo "HockeyApp upload successful" | |
else | |
echo "HockeyApp upload failed" | |
# unfortunately this doesn't let the build fail | |
exit -1 | |
fi | |
else | |
echo "HOCKEYAPP_CREDENTIALS env var missing. Aborting" | |
fi | |
else | |
echo "WORKSPACE env var missing. Aborting..." | |
exit -1 | |
fi | |
else | |
#interactive Xcode mode | |
open -a HockeyApp "${ARCHIVE_PATH}" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment