Skip to content

Instantly share code, notes, and snippets.

@randombrein
Last active January 1, 2016 22:39
Show Gist options
  • Save randombrein/bdd50616dfa9c024bc48 to your computer and use it in GitHub Desktop.
Save randombrein/bdd50616dfa9c024bc48 to your computer and use it in GitHub Desktop.
Xcode post-build action script to send adhoc to TestFlight over Upload API.
#!/bin/bash
################################
# Xcode post-build action script
# to send adhoc to TestFlight over Upload API
#
TESTFLIGHT_BUILD=1
if [[ $TESTFLIGHT_BUILD -ne 1 ]]
then
exit
fi
LOGFILE=$BUILT_PRODUCTS_DIR"/postaction_log.txt"
IPAFILE="Payload"
exec > $LOGFILE 2>&1
cd $BUILT_PRODUCTS_DIR
echo "*** POST BUILD ACTION ***"
pwd
##############
# Prepare data
#
UP_APPFILE="${IPAFILE}.ipa"
UP_SYMFILE="${TARGETNAME}.app.dSYM.zip"
rm -rf "$UP_APPFILE"
rm -rf "$UP_SYMFILE"
#app file
mkdir -p "$IPAFILE"
cp -R "${TARGETNAME}.app" "$IPAFILE"
zip -r "${IPAFILE}.zip" "$IPAFILE"
mv "${IPAFILE}.zip" "$UP_APPFILE"
rm -rf "$IPAFILE"
#sym file
zip -r "$UP_SYMFILE" "${TARGETNAME}.app.dSYM"
echo "sending "$UP_APPFILE"..."
echo "sending "$UP_SYMFILE"..."
# https://testflightapp.com/api/doc/
#
# REQUEST:
# HTTP Method: POST
# URL: http://testflightapp.com/api/builds.format
# Response formats: xml, json, plist
#
# Fields:
#
# api_token - Required (Get your API token)
# team_token - Required, token for the team being uploaded to.
# file - Required, file data for the build
# notes - Required, release notes for the build
# dsym - iOS ONLY - Optional, the zipped .dSYM corresponding to the build
# distribution_lists - Optional, comma separated distribution list names which will receive access to the build
# notify - Optional, notify permitted teammates to install the build (defaults to False)
# replace - Optional, replace binary for an existing build if one is found with the same name/bundle version (defaults to False)
#
#
# RESPONSE:
# Status: 200 OK
# Sample JSON response:
# {
# "bundle_version": "0.91",
# "install_url": "http://testflightapp.com/install/0199f7eccd5e4966d0a3cbe7fcd00773-Mjc/",
# "config_url": "http://testflightapp.com/dashboard/builds/complete/27/",
# "created_at": "2010-11-18 14:51:55",
# "device_family": "Universal",
# "notify": false,
# "team": "Air Support",
# "minimum_os_version": "3.0",
# "release_notes": "This build was uploaded via the upload api",
# "binary_size": 6280557
# }
###########
# Send data
#
API_TOKEN="63fbb02cef4541cb8ff16c7f86334fdd_MTU0MjE4OTIwMTMtMTItMzEgMTQ6MDQ6MjguNTExNzI4"
TEAM_TOKEN="13bae3a6ee0048ba14144f67b68ddef8_MzE5MjUwMjAxMy0xMi0zMSAxNDowODoxNC43Mjk5OTE"
UP_NOTES="uploaded using Testflight Upload API"
curl http://testflightapp.com/api/builds.json \
-F file=@"$UP_APPFILE" \
-F dsym=@"$UP_SYMFILE" \
-F api_token="$API_TOKEN" \
-F team_token="$TEAM_TOKEN" \
-F notes="$UP_NOTES" \
-F notify=False \
-F replace=True &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment