Skip to content

Instantly share code, notes, and snippets.

@bendjones
Created January 9, 2015 18:25
Show Gist options
  • Save bendjones/4399e0e87d06e7017ae5 to your computer and use it in GitHub Desktop.
Save bendjones/4399e0e87d06e7017ae5 to your computer and use it in GitHub Desktop.
Xcode Bot Server Post-Archive action script to generate builds using Beta Builder and notify Slack
# BEGIN EDITABLE AREA
# replace with slack hook URL for slack support
SLACK_HOOK_URL="https://hooks.slack.com/services/RELACE_WITH_FULL_HOOK_URL"
# check if we're running as the bot or as an archive step from xcode, change as needed
if [ "${INSTALL_OWNER}" = "_xcsbuildd" ]
then
BETA_OUTPUT_FOLDER="/usr/local/var/www/${PRODUCT_NAME}/${FULL_VERSION}"
BETA_LATEST_FOLDER="/usr/local/var/www/${PRODUCT_NAME}/latest"
REMOTE_WEBSITE_ROOT="https://botServerURL.com/${PRODUCT_NAME}/latest"
else
BETA_OUTPUT_FOLDER="/Users/${INSTALL_OWNER}/Dropbox/Public/${PRODUCT_NAME}/${FULL_VERSION}"
BETA_LATEST_FOLDER="/Users/${INSTALL_OWNER}/Dropbox/Public/${PRODUCT_NAME}/latest"
REMOTE_WEBSITE_ROOT="REPLACE WITH DROPBOX URL"
fi
#!/bin/sh
DSYM="${ARCHIVE_DSYMS_PATH}/${PRODUCT_NAME}.app.dSYM"
IPA="/tmp/${PRODUCT_NAME}.ipa"
APP="/tmp/Archive.xcarchive/Products/Applications/${PRODUCT_NAME}.app"
# Remove previous archive files from tmp folder
echo "Removing old Archive files from /tmp...";
/bin/rm -rf /tmp/Archive.xcarchive
# Copy over the latest archive to tmp folder
echo "Copying latest Archive to /tmp...";
/bin/cp -Rp "${ARCHIVE_PATH}" "/tmp/Archive.xcarchive"
PLIST_FILE="/tmp/Archive.xcarchive/Info.plist"
BUNDLE_VERSION=$(/usr/libexec/plistbuddy -c "Print:ApplicationProperties:CFBundleVersion" ${PLIST_FILE})
SHORT_VERSION=$(/usr/libexec/plistbuddy -c "Print:ApplicationProperties:CFBundleShortVersionString" ${PLIST_FILE})
FULL_VERSION="${SHORT_VERSION}.${BUNDLE_VERSION}"
# Create .ipa in tmp folder
echo "Creating .ipa for ${PRODUCT_NAME}..."
/bin/rm "${IPA}"
/bin/rm -fr "${BETA_OUTPUT_FOLDER}"
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${APP}" -o "${IPA}"
echo "Created .ipa for ${PRODUCT_NAME}."
/bin/mkdir -p "${BETA_OUTPUT_FOLDER}"
echo "Creating Beta Builder Pages for ${PRODUCT_NAME}..."
"/Applications/BetaBuilder for iOS Apps.app/Contents/MacOS/BetaBuilder for iOS Apps" -ipaPath=${IPA} -outputDirectory=${BETA_OUTPUT_FOLDER} -webserver=${REMOTE_WEBSITE_ROOT}
echo "Updating latest symbolic link ${BETA_LATEST_FOLDER} to map to ${BETA_OUTPUT_FOLDER}"
/bin/rm -fr ${BETA_LATEST_FOLDER}
/bin/ln -shfn "${BETA_OUTPUT_FOLDER}" "${BETA_LATEST_FOLDER}"
echo "Latest build is now at ${BETA_LATEST_FOLDER}"
# OPTIONAL SLACK NOTIFICATION
/usr/bin/curl -X POST --data-urlencode "payload={\"username\": \"xcode-server\", \"text\": \"Build ${FULL_VERSION} of ${PRODUCT_NAME} has just finished download here: <${REMOTE_WEBSITE_ROOT}|Check it out>\"}" ${SLACK_HOOK_URL}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment