Created
September 6, 2014 18:43
-
-
Save lucascorrea/3add29341d02c7166f74 to your computer and use it in GitHub Desktop.
Build automatic Testflighapp via xcode
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 | |
# | |
# (Above line comes out when placing in Xcode scheme) | |
# | |
# gem install terminal-notifier and sudo gem install terminal-notifier | |
API_TOKEN="" | |
TEAM_TOKEN="" | |
SIGNING_IDENTITY="iPhone Distribution: Name" | |
PROVISIONING_FILENAME="Filename provision" | |
DISTRIBUTION_LISTS="List testfligtapp" | |
DATE=$( /bin/date +"%Y-%m-%d" ) | |
ARCHIVE=$( /bin/ls -t "${HOME}/Library/Developer/Xcode/Archives/${DATE}" | /usr/bin/grep xcarchive | /usr/bin/sed -n 1p ) | |
DSYM="${HOME}/Library/Developer/Xcode/Archives/${DATE}/${ARCHIVE}/dSYMs/${PRODUCT_NAME}.app.dSYM" | |
APP="${HOME}/Library/Developer/Xcode/Archives/${DATE}/${ARCHIVE}/Products/Applications/${PRODUCT_NAME}.app" | |
PROVISIONING_PROFILE=`grep -r $PROVISIONING_FILENAME $HOME/Library/MobileDevice/Provisioning\ Profiles -l -i` | |
LOG="/tmp/testflight.log" | |
NOTIFY="/usr/bin/terminal-notifier -message -title BuildTestflight" | |
rm $LOG | |
echo "${PROVISIONING_PROFILE}" >> $LOG | |
echo "Creating .ipa for ${PRODUCT_NAME}..." >> $LOG | |
echo "Creating .ipa for ${PRODUCT_NAME}" | ${NOTIFY} | |
/bin/rm "/tmp/${PRODUCT_NAME}.ipa" | |
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${APP}" -o "/tmp/${PRODUCT_NAME}.ipa" --sign "${SIGNING_IDENTITY}" --embed "${PROVISIONING_PROFILE}" | |
echo "Zipping .dSYM for ${PRODUCT_NAME}..." >> $LOG | |
echo "Zipping .dSYM for ${PRODUCT_NAME}" | ${NOTIFY} | |
/bin/rm "/tmp/${PRODUCT_NAME}.dSYM.zip" | |
/usr/bin/zip -r "/tmp/${PRODUCT_NAME}.dSYM.zip" "${DSYM}" | |
echo "Created .dSYM for ${PRODUCT_NAME}" >> $LOG | |
echo "Created .dSYM for ${PRODUCT_NAME}" | ${NOTIFY} | |
echo "Uploading to TestFlight... " >> $LOG | |
echo "Uploading to TestFlight" | ${NOTIFY} | |
echo "/usr/bin/curl -v --silent http://testflightapp.com/api/builds.json \ | |
-F file=@/tmp/${PRODUCT_NAME}.ipa \ | |
-F dsym=@/tmp/${PRODUCT_NAME}.dSYM.zip \ | |
-F notify=True \ | |
-F api_token='${API_TOKEN}' \ | |
-F team_token='${TEAM_TOKEN}' \ | |
-F distribution_lists='${DISTRIBUTION_LISTS}' \ | |
-F notes='Build uploaded automatically from Xcode.'" >> $LOG | |
OUTPUT=`curl -s "http://testflightapp.com/api/builds.json" \ | |
-F file=@"/tmp/${PRODUCT_NAME}.ipa" \ | |
-F dsym=@"/tmp/${PRODUCT_NAME}.dSYM.zip" \ | |
-F api_token="${API_TOKEN}" \ | |
-F team_token="${TEAM_TOKEN}" \ | |
-F distribution_lists="${DISTRIBUTION_LISTS}" \ | |
-F notify="True" \ | |
-F notes="Build uploaded automatically from Xcode."` | |
echo "Retorno: $OUTPUT" >> $LOG | |
CONFIG_URL=`echo $OUTPUT | sed -e 's/^.*"config_url"[ ]*:[ ]*"//' -e 's/".*//'` | |
echo "TestFlight: $CONFIG_URL" >> $LOG | |
if [[ "$CONFIG_URL" == *"permissions"* ]]; then | |
echo "Finished the process testflightapp and sent email to testers." | ${NOTIFY} -s && /usr/bin/open "$CONFIG_URL" | |
else | |
echo "Error: $OUTPUT" >> $LOG | |
echo "Error: $OUTPUT" | ${NOTIFY} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment