Skip to content

Instantly share code, notes, and snippets.

@mbehan
Last active May 19, 2016 07:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbehan/11214790 to your computer and use it in GitHub Desktop.
Save mbehan/11214790 to your computer and use it in GitHub Desktop.
Uploads builds produced by Xcode bots
#!/bin/bash
files=/ci_scripts/*.plist
for f in $files
do
echo Processing $f "..."
productName="$(/usr/libexec/plistbuddy -c Print:ProductName: "$f")"
echo $productName
ipaPath=$(find /Library/Server/Xcode/Data/BotRuns/*/output/"$productName" -mtime -15m | head -1)
if [ ${#ipaPath} -gt 0 ]; then
echo "Have IPA FILE: " $ipaPath
method="$(/usr/libexec/plistbuddy -c Print:Method: "$f")"
if [ $method == "FTP" ]; then
echo "Attempting FTP ..."
host="$(/usr/libexec/plistbuddy -c Print:FTPHost: "$f")"
user="$(/usr/libexec/plistbuddy -c Print:UserName: "$f")"
pass="$(/usr/libexec/plistbuddy -c Print:Password: "$f")"
filename="$(/usr/libexec/plistbuddy -c Print:FileNameOnServer: "$f")"
hostDir="$(/usr/libexec/plistbuddy -c Print:DirectoryOnServer: "$f")"
date=`date +%y-%m-%d`
ftp -inv $host <<-ENDFTP
user $user $pass
cd $hostDir
mkdir $date
cd $date
binary
put "$ipaPath" "$filename"
bye
ENDFTP
elif [ $method == "TestFlight" ]; then
echo "Attempting TestFlight ..."
apiToken="$(/usr/libexec/plistbuddy -c Print:APIToken: "$f")"
teamToken="$(/usr/libexec/plistbuddy -c Print:TeamToken: "$f")"
/usr/bin/curl "http://testflightapp.com/api/builds.json" \
-F file=@"$ipaPath" \
-F api_token="$apiToken" \
-F team_token="$teamToken" \
-F notes="Automated Build"
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment