Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mattvlasach/7220329 to your computer and use it in GitHub Desktop.
Save mattvlasach/7220329 to your computer and use it in GitHub Desktop.
This script is intended to be run as a Post-Action Shell Script on an Archive action, on an Xcode Continuous Integration server. See http://matt.vlasach.com/xcode-bots-hosted-git-repositories-and-automated-testflight-builds/ for a full step-by-step guide.
#!/bin/bash
#
# (Above line comes out when placing in Xcode scheme)
#
# Valid and working as of 10/29/2013
# Xcode 5.0.1, XCode Server
#
API_TOKEN="<Your TesFlight API Token>"
TEAM_TOKEN="<Your TestFlight Team Token>"
DISTRIBUTION_LISTS="<Comma separated TestFlight Distribution List Names for auto deploy>"
PROVISIONING_PROFILE="/Library/Server/Xcode/Data/ProvisioningProfiles/<your file name here>.mobileprovision"
#EXAMPLE:"/Library/Server/Xcode/Data/ProvisioningProfiles/DocLink_InHouse_2013.mobileprovision"
SIGNING_IDENTITY="<your provisioning profile name here>"
#EXAMPLE:"iPhone Distribution: Unwired Revolution, LLC."
# DO NOT EDIT BELOW HERE!
########################################
DSYM="/tmp/Archive.xcarchive/dSYMs/${PRODUCT_NAME}.app.dSYM"
IPA="/tmp/${PRODUCT_NAME}.ipa"
APP="/tmp/Archive.xcarchive/Products/Applications/${PRODUCT_NAME}.app"
# Clear out any old copies of the Archive
echo "Removing old Archive files from /tmp...";
/bin/rm -rf /tmp/Archive.xcarchive*
#Copy over the latest build the bot just created
echo "Copying latest Archive to /tmp/...";
LATESTBUILD=$(ls -1rt /Library/Server/Xcode/Data/BotRuns | tail -1)
/bin/cp -Rp "/Library/Server/Xcode/Data/BotRuns/${LATESTBUILD}/output/Archive.xcarchive" "/tmp/"
echo "Creating .ipa for ${PRODUCT_NAME}"
/bin/rm "${IPA}"
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${APP}" -o "${IPA}" --sign "${SIGNING_IDENTITY}" --embed "${PROVISIONING_PROFILE}"
echo "Done with IPA creation."
echo "Zipping .dSYM for ${PRODUCT_NAME}"
/bin/rm "${DSYM}.zip"
/usr/bin/zip -r "${DSYM}.zip" "${DSYM}"
echo "Created .dSYM for ${PRODUCT_NAME}"
echo "*** Uploading ${PRODUCT_NAME} to TestFlight ***"
/usr/bin/curl "http://testflightapp.com/api/builds.json" \
-F file=@"${IPA}" \
-F dsym=@"${DSYM}.zip" \
-F api_token="${API_TOKEN}" \
-F team_token="${TEAM_TOKEN}" \
-F distribution_lists="${DISTRIBUTION_LISTS}" \
-F notes="Build uploaded automatically from Xcode Server Bot."
echo "TestFlight upload finished!"
@alejandrojimenez
Copy link

It doesn't work on Xcode 6 anymore :-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment