|
# redirect to the log file |
|
|
|
exec > /tmp/tf_upload.log 2>&1 |
|
|
|
# Open terminal window for tracking the logs |
|
osascript <<EOF |
|
tell app "Terminal" |
|
activate |
|
do script ("tail -f /tmp/tf_upload.log") |
|
end tell |
|
EOF |
|
|
|
# Ultra verbose mode |
|
set -x |
|
|
|
# Print env variables |
|
printenv |
|
# Setup the terminal notifier (requires https://github.com/alloy/terminal-notifier) |
|
# Allows showing poping notifications from Terminal |
|
GROWL="terminal-notifier -title Testflight -message" |
|
|
|
#setup the vars |
|
DSYM="${ARCHIVE_DSYMS_PATH}/${PRODUCT_NAME}.app.dSYM" |
|
APP="${ARCHIVE_PRODUCTS_PATH}/Applications/${PRODUCT_NAME}.app" |
|
PROVISIONING_PROFILE="${APP}/${EMBEDDED_PROFILE_NAME}" |
|
|
|
# Send to Notification Center |
|
${GROWL} "Creating .ipa for ${PRODUCT_NAME}" |
|
|
|
# Remove previous build |
|
/bin/rm "/tmp/${PRODUCT_NAME}.ipa" |
|
|
|
# Package and Sign |
|
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${APP}" -o "/tmp/${PRODUCT_NAME}.ipa" --sign "${CODE_SIGN_IDENTITY}" --embed "${PROVISIONING_PROFILE}"; |
|
|
|
${GROWL} "Created .ipa for ${PRODUCT_NAME}" |
|
|
|
${GROWL} "Zipping .dSYM for ${PRODUCT_NAME}" |
|
|
|
/bin/rm "/tmp/${PRODUCT_NAME}.dSYM.zip" |
|
/usr/bin/zip -r "/tmp/${PRODUCT_NAME}.dSYM.zip" "${DSYM}" |
|
|
|
${GROWL} "Created .dSYM for ${PRODUCT_NAME}" |
|
|
|
${GROWL} "Uploading to TestFlight" |
|
|
|
NOTES="Build uploaded automatically from Xcode." |
|
if [[ "$TF_USE_GIT_LOG" -ne 0 ]] |
|
then |
|
PWD=$(pwd) |
|
cd ${PROJECT_DIR} |
|
|
|
# Read the last archive Key |
|
LAST_ARCHIVE_KEY=TFLastArchive |
|
|
|
# Read the last archive time |
|
LAST_ARCHIVE=$(defaults read ${PROJECT_DIR}/${INFOPLIST_FILE} ${LAST_ARCHIVE_KEY}) |
|
|
|
if [ -z "$LAST_ARCHIVE" ] |
|
then |
|
LAST_ARCHIVE=$(date -v "-4w" "+%Y-%m-%d %H:%M"); |
|
fi |
|
|
|
# Get the notes |
|
NOTES=$(git log --pretty="%h - %s" -${TF_USE_GIT_LOG} --since="${LAST_ARCHIVE}") |
|
|
|
cd $PWD; |
|
|
|
fi |
|
|
|
/usr/bin/curl "http://testflightapp.com/api/builds.json" \ |
|
-F file=@"/tmp/${PRODUCT_NAME}.ipa" \ |
|
-F dsym=@"/tmp/${PRODUCT_NAME}.dSYM.zip" \ |
|
-F api_token="${TF_API_TOKEN}" \ |
|
-F team_token="${TF_TEAM_TOKEN}" \ |
|
-F distribution_lists="${TF_DISTRIBUTION_LISTS}" \ |
|
-F notify="${TF_NOTIFY}" \ |
|
-F notes="${NOTES}" |
|
|
|
${GROWL} "Uploaded to TestFlight" |
|
|
|
NOW=$(date "+%Y-%m-%d %H:%M"); |
|
|
|
#Update the last archive key |
|
$(defaults write ${PROJECT_DIR}/${INFOPLIST_FILE} "${LAST_ARCHIVE_KEY}" "${NOW}"); |