Created
November 2, 2012 18:06
-
-
Save jhosmer/4003247 to your computer and use it in GitHub Desktop.
Upload a zipped dSYM to Crittercism
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/sh | |
######################################################################################################## | |
######################################################################################################## | |
## Author: Jonathan Hosmer (http://pythonforios.com) ## | |
## Date: 2 November 2012 ## | |
######################################################################################################## | |
######################################################################################################## | |
### ** How to use this script ** ### | |
### Add a 'Run Script' build phase and enter the path to this script ### | |
### Include these macros in your xcconfig Config file or the 'Build Settings' tab of the Project ### | |
### (GCC_PREPROCESSOR_DEFINITIONS or GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS) ### | |
### CRITTERCISM=1 ### | |
### CRITTERCISM_APP_ID=\@\"123456789012345678901234\" ### | |
### CRITTERCISM_APP_KEY=\@\"12345678901234567890123456789012\" ### | |
### CRITTERCISM_APP_SECRET=\@\"12345678901234567890123456789012\" ### | |
### /*** Replace the 3 values above with your own App ID, App Key, App Secret ***/ ### | |
######################################################################################################## | |
######################################################################################################## | |
#### Copyright © 2012 Jonathan Hosmer #### | |
#### #### | |
#### Permission is hereby granted, free of charge, to any person obtaining #### | |
#### a copy of this software and associated documentation files (the #### | |
#### Software), to deal in the Software without restriction, including #### | |
#### without limitation the rights to use, copy, modify, merge, publish, #### | |
#### distribute, sublicense, and/or sell copies of the Software, and to #### | |
#### permit persons to whom the Software is furnished to do so, subject to #### | |
#### the following conditions: #### | |
#### #### | |
#### The above copyright notice and this permission notice shall be #### | |
#### included in all copies or substantial portions of the Software. #### | |
#### #### | |
#### THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, #### | |
#### EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF #### | |
#### MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND #### | |
#### NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE #### | |
#### LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION #### | |
#### OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION #### | |
#### WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #### | |
######################################################################################################## | |
######################################################################################################## | |
############################################# Script Start ############################################# | |
######################################################################################################## | |
set -e | |
NOW=`date "+%Y-%m-%d %H:%M:%S %Z"` | |
ME=$(/usr/bin/basename "${0}") | |
SCRIPT_EXT=".${ME##*.}" | |
SCRIPT_NAME=$(/usr/bin/basename "${ME}" "${SCRIPT_EXT}") | |
PLIST_BUDDY="/usr/bin/PlistBuddy" | |
BUNDLE_VERSION_KEY="CFBundleVersion" # i.e. build number - ex: 792 | |
BUNDLE_SHORT_VERSION_KEY="CFBundleShortVersionString" # i.e. MAJOR.MINOR.MICRO version number - ex: 1.3.1 | |
TMP_IFS="${IFS}" | |
export IFS='"' | |
BUILD_NUM=`"${PLIST_BUDDY}" -c "Print :${BUNDLE_VERSION_KEY}" "${SOURCE_ROOT}/${INFOPLIST_FILE}"` | |
VERSION_NUM=`"${PLIST_BUDDY}" -c "Print :${BUNDLE_SHORT_VERSION_KEY}" "${SOURCE_ROOT}/${INFOPLIST_FILE}"` | |
LOG_DIR="/var/log/${PROJECT_NAME}/${PRODUCT_NAME}/${VERSION_NUM}" | |
test ! -d "${LOG_DIR}" && mkdir -p "${LOG_DIR}" | |
LOG_FILE="${LOG_DIR}/${SCRIPT_NAME}-${BUILD_NUM}.log" | |
echoLog() { echo "${1}" | tee -a "${LOG_FILE}"; } | |
exitWithMessageAndCode() { | |
echoLog "${1}" | |
export IFS="${TMP_IFS}" | |
exit "${2}" | |
} | |
CRITTERCISM= | |
CRITTERCISM_APP_ID= | |
CRITTERCISM_APP_KEY= | |
CRITTERCISM_APP_SECRET= | |
export IFS="${TMP_IFS}" | |
for def in ${GCC_PREPROCESSOR_DEFINITIONS} ${GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS}; do | |
DEF_NAME=$( echo "${def}" | cut -d'=' -f 1 ) | |
DEF_VALUE=$( echo "${def}" | cut -d'=' -f 2 | tr -d '\\@"') | |
if test "${DEF_NAME}" = "CRITTERCISM" -a "${DEF_VALUE}" = "1"; then | |
CRITTERCISM="${DEF_VALUE}" | |
elif test "${DEF_NAME}" = "CRITTERCISM_APP_ID"; then | |
CRITTERCISM_APP_ID="${DEF_VALUE}" | |
elif test "${DEF_NAME}" = "CRITTERCISM_APP_KEY"; then | |
CRITTERCISM_APP_KEY="${DEF_VALUE}" | |
elif test "${DEF_NAME}" = "CRITTERCISM_APP_SECRET"; then | |
CRITTERCISM_APP_SECRET="${DEF_VALUE}" | |
fi | |
done | |
export IFS='"' | |
echoLog "CRITTERCISM=${CRITTERCISM} - CRITTERCISM_APP_ID=${CRITTERCISM_APP_ID} - CRITTERCISM_APP_KEY=${CRITTERCISM_APP_KEY} - CRITTERCISM_APP_SECRET=${CRITTERCISM_APP_SECRET}" | |
test "${CRITTERCISM}" && echoLog "Uploading dSYM to Crittercism..." || exitWithMessageAndCode "No 'CRITTERCISM' macro found (or macro set to 0). Not uploading dSYM to Crittercism." 0 | |
CRITTERCISM_DSM_UPLOAD_URL="https://www.crittercism.com/api_beta/dsym/${CRITTERCISM_APP_ID}" | |
DSYM_BASE_NAME="${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}" | |
DSYM_PATH_NAME="${DSYM_BASE_NAME}/Contents/Resources/DWARF/${PRODUCT_NAME}" | |
DSYM_ZIP_FPATH="${DSYM_BASE_NAME}.zip" | |
# clean old dSYM .zip file | |
test -e "${DSYM_ZIP_FPATH}" && (echoLog "Removing existing dSYM zip archive..." && rm -f -v "${DSYM_ZIP_FPATH}" >> "${LOG_FILE}") | |
# create dSYM .zip file | |
test -e "${DSYM_PATH_NAME}" && (echoLog "Creating zip of dSYM file..." && zip -r "${DSYM_ZIP_FPATH}" "${DSYM_PATH_NAME}" >> "${LOG_FILE}") || exitWithMessageAndCode "Could not find dSYM file to zip at: ${DSYM_PATH_NAME}" 1 | |
# Upload App to TestFlight and notify testers | |
echoLog "Uploading dSYM to Crittercism..." | |
curl "${CRITTERCISM_DSM_UPLOAD_URL}" --progress-bar \ | |
-F dsym=@"${DSYM_ZIP_FPATH}" \ | |
-F key=${CRITTERCISM_APP_KEY} \ | |
-F secret=${CRITTERCISM_APP_SECRET} \ | |
>>"${LOG_FILE}" 2>&1 | |
exitWithMessageAndCode "Crittercism upload complete!" 0 | |
######################################################################################################## | |
############################################## Script End ############################################## | |
######################################################################################################## | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment