Last active
May 6, 2016 12:39
-
-
Save kevinrenskers/2e7308628c11ca466103 to your computer and use it in GitHub Desktop.
iOS build script
This file contains hidden or 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/bash | |
ARCHIVE_DEST_PATH="./archive" | |
ARCHIVE_PACKAGE="$ARCHIVE_DEST_PATH.xcarchive" | |
# Remove old archive | |
if [ -f "$ARCHIVE_PACKAGE/Info.plist" ]; then | |
rm -r "$ARCHIVE_PACKAGE" | |
fi | |
# Are there any commits since the last tag? | |
git fetch --tags | |
lastTag=$(git for-each-ref --sort=-taggerdate --format='%(refname:short)' refs/tags --count 1) | |
commitsSinceLastTag=$(git rev-list $lastTag..HEAD) | |
if [ -z "$commitsSinceLastTag" ] | |
then | |
echo "No new commits, abort" | |
exit | |
fi | |
# Make sure cocoapods is in sync | |
pod install | |
plist=$(find . -regex '^.*\/Supporting Files\/sling-Info.plist$') | |
widgetPlist=$(find . -regex '^.*\/Sling Widget\/Info.plist$') | |
versionNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "$plist") | |
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$plist") | |
# Increase the build number by one | |
buildNumber=$(($buildNumber + 1)) | |
# Set the new build number | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$plist" | |
# Also do it for the widget | |
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $versionNumber" "$widgetPlist" | |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$widgetPlist" | |
# Create the build | |
xcodebuild -archivePath "$ARCHIVE_DEST_PATH" -workspace sling.xcworkspace -scheme sling -sdk iphoneos clean archive | |
if [ -f "$ARCHIVE_PACKAGE/Info.plist" ]; then | |
# Save the git log into notes.md | |
git log --pretty=format:'* %s [%an]' --abbrev-commit --dense --no-merges --reverse ...$lastTag > notes.md | |
# Edit the notes, make it nice and readable, edit out any nonsense | |
pico notes.md | |
notes="`cat notes.md`" | |
# Save notes into changelog | |
echo "$versionNumber-$buildNumber (`date +"%Y-%m-%d %H:%M"`)" >> temp_changelog.md | |
cat notes.md >> temp_changelog.md # save the new notes into temp_changelog | |
echo "" >> temp_changelog.md # force newline | |
cat changelog.md >> temp_changelog.md # append the old changelog to the new notes | |
mv temp_changelog.md changelog.md # temp_changelog becomes changelog! | |
rm -f notes.md | |
# Commit, set git tag | |
git add . | |
git commit -m "Build $buildNumber" | |
tag="$versionNumber-$buildNumber" | |
git tag -a $tag -m "$tag" | |
git push origin $tag | |
git push origin | |
# Submit to HockeyApp | |
if [ -f "/usr/local/bin/puck" ]; then | |
echo "Submitting to Hockey..." | |
/usr/local/bin/puck -submit=auto -download=false -notes_type=markdown -notes="$notes" -api_token=a880a9f4ddff40efa41c6c4b598cfd5a -app_id=144ce4a276afba2591a4dc7c48f076c5 "$ARCHIVE_PACKAGE" | |
fi | |
# Submit to TestFlight (for now simply open it in Xcode, do it manually from there) | |
open "$ARCHIVE_PACKAGE" | |
# Create an IPA that we then put on iOS 7 devices via iTunes | |
# xcodebuild -exportArchive -archivePath "$ARCHIVE_PACKAGE" -exportPath sling.ipa -exportFormat IPA -exportProvisioningProfile "XC Ad Hoc: is.gangverk.sling" | |
# Move the IPA to Dropbox | |
# mv sling.ipa ~/Dropbox\ \(Gangverk\)/Gangverk/Sling | |
else | |
echo "Archive failed!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment