-
-
Save walm/3996558 to your computer and use it in GitHub Desktop.
xcode build & upload testflight from coomand line
This file contains 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/sh | |
######CONFIG##### | |
# TestFlight API Token | |
# from https://testflightapp.com/dashboard/team/edit/ | |
# $ git config --global testflight.apitoken XXX | |
# form https://testflightapp.com/account/#api | |
# $ git config --global testflight.teamtoken XXX | |
# Testflight API token | |
API_TOKEN=$(git config testflight.apitoken) | |
TEAM_TOKEN=$(git config testflight.teamtoken) | |
# scheme name of Xcode | |
SCHEME_NAME="testflight" | |
# configurations name of Xcode | |
CONFIGURATION_NAME="Adhoc" | |
################# | |
HOOKS_DIR="~/sh/deploy_testflight/hooks" | |
warn() { echo "$@" >&2; } | |
die() { warn "Fatal: $@"; exit 1; } | |
# | |
# run_pre_hook | |
# | |
run_pre_hook() { | |
local scriptfile="${HOOKS_DIR}/pre-testflight" | |
local exitcode=0 | |
if [ -x $scriptfile ]; then | |
$scriptfile "$@" | |
exitcode=$? | |
if [ $exitcode -gt 0 ]; then | |
die "Hook command $scriptfile ended with exit code $exitcode." | |
fi | |
fi | |
} | |
# | |
# run_post_hook | |
# | |
run_post_hook() { | |
local scriptfile="${HOOKS_DIR}/post-testflight" | |
if [ -x $scriptfile ]; then | |
$scriptfile "$@" | |
fi | |
} | |
# delete previous build files | |
[ -d build/ ] && rm -r build/ | |
run_pre_hook | |
# Project Name | |
PROJECT_NAME=$(find . -name "*.xcodeproj" -maxdepth 1 -exec basename {} .xcodeproj \;) | |
# $ xcode build | |
xcodebuild -sdk "iphoneos" -configuration ${CONFIGURATION_NAME} -scheme ${SCHEME_NAME} clean build CONFIGURATION_BUILD_DIR=./build | |
# get mobileprovision path | |
MOBILE_PROVISION_FILE="build/${PROJECT_NAME}.app/embedded.mobileprovision" | |
# $ generate ipa file | |
IPA_FILE="$(pwd)/build/${PROJECT_NAME}.ipa" | |
xcrun -sdk iphoneos PackageApplication "$(pwd)/build/${PROJECT_NAME}.app" -o ${IPA_FILE} --embed "build/${PROJECT_NAME}.app/embedded.mobileprovision" | |
# make dsym.zip | |
DSYM_FILE="${PROJECT_NAME}.app.dSYM.zip" | |
/usr/bin/zip -r ${DSYM_FILE} "$(pwd)/build/${PROJECT_NAME}.app.dSYM/" | |
# https://testflightapp.com/api/doc/#curl | |
curl http://testflightapp.com/api/builds.json \ | |
-F file=@${IPA_FILE} \ | |
-F dsym=@${DSYM_FILE} \ | |
-F api_token=${API_TOKEN} \ | |
-F team_token=${TEAM_TOKEN} \ | |
-F notes='default note' \ | |
--progress-bar \ | |
| ruby -rjson -e "puts JSON.parse(ARGF.read)['config_url'].sub(/complete/,'edit')" \ | |
| xargs open | |
run_post_hook |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment