Skip to content

Instantly share code, notes, and snippets.

@kitschpatrol
Created May 9, 2014 14:36
Show Gist options
  • Select an option

  • Save kitschpatrol/74f7b7fc786fd1507476 to your computer and use it in GitHub Desktop.

Select an option

Save kitschpatrol/74f7b7fc786fd1507476 to your computer and use it in GitHub Desktop.
Deploy to Testflight
#!/bin/bash
echo "Building and Deploying App to TestFlight"
# Move up a level to build directory
cd ..
# Check for Nomad: http://nomad-cli.com
if ! command -v ipa 2>/dev/null; then
echo "Nomad is required! Please run \"gem install nomad-cli\""
echo "Aborting build"
exit 1;
fi
# Check for environment variables
if [ -e ./.env ] ; then
set -a
. .env
else
echo "Deployment expects a .env file in the project root with values for the TestFlight API_TOKEN and TEAM_TOKEN."
echo "Aborting build"
exit 1;
fi
# Check if directory is clean
if [ -n "$(git status --porcelain)" ]; then
echo "The working directory is dirty. Please commit your changes before deploying."
echo "Aborting build"
exit 1;
fi
# Build app
ipa build \
--clean \
--scheme $DEPLOYMENT_SCHEME \
--configuration Release \
--embed $AD_HOC_DISTRIBUTION_PROVISIONING_PROFILE \
--identity "$AD_HOC_DISTRIBUTION_SIGNING_IDENTITY"
# Release notes
# Create the folder if needed
mkdir -p ReleaseNotes
#TOTO print commit messages since last release
echo "Commits since last release:"
LAST_RELEASE_TAG=`git tag | grep _App_ | tail -n 1`
COMMIT_LOG=`git shortlog $LAST_RELEASE_TAG..HEAD`
echo "------------------"
echo "$COMMIT_LOG"
echo "------------------"
echo "Create Release Notes. Save and quit the editor when you are finished."
echo
BUILD_NUMBER=`cat BuildNumber`
RELEASE_NOTES_FILE="ReleaseNotes/$BUILD_NUMBER-notes.txt"
touch "$RELEASE_NOTES_FILE"
open -t -W "$RELEASE_NOTES_FILE"
echo "Saved release notes. Deploying."
# Deploy to TestFlight
NOTIFY_FLAG=""
if [ "$EMAIL_USERS_ABOUT_UPDATE" = true ] ; then
NOTIFY_FLAG="--notify"
fi;
ipa distribute:testflight \
--file "$APP_FILE_NAME.ipa" \
--dsym "$APP_FILE_NAME.app.dSYM.zip" \
--api_token $TEST_FLIGHT_API_TOKEN \
--team_token $TEST_FLIGHT_TEAM_TOKEN \
--notes "$(cat $RELEASE_NOTES_FILE)" \
--lists "$TEST_FLIGHT_DISTRIBUTION_LIST" \
$NOTIFY_FLAG
echo "Ammending latest commit with release notes and build file"
git add .
git commit -m "Update release notes."
echo "Tagging the latest commit"
echo Tagging current head with \"TestFlight_$BUILD_NUMBER\"
`git tag TestFlight_$BUILD_NUMBER`
echo "Done!"
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment