Skip to content

Instantly share code, notes, and snippets.

@akinLiu
Forked from icyleaf/umeng_ios_publish_channel_package_tool.sh
Created June 26, 2012 17:08
Show Gist options
  • Save akinLiu/2997161 to your computer and use it in GitHub Desktop.
Save akinLiu/2997161 to your computer and use it in GitHub Desktop.
iOS 友盟发布渠道自动化脚本
#
# iOS 友盟发布渠道自动化脚本
#
# - 在 Archive 的 "Post-action" 添加脚本去执行 "/bin/sh $SRCROOT/package.sh"
# - 确保在 "Provide build setting from" 选择了当前的 App
# - 在项目根目录($SRCROOT)添加 "iTunesArtwork" 文件(符合 App Store 提交要求的 512x512 px, PNG 格式)
# - 在下面 "" 设置你需要的发布渠道(空格分隔)
# - 在下面设置打包后的 ipa 的输出路径(可选)
# - 执行 "Product > Archive"
#
# icyleaf <icyleaf.cn@gmail.com>
# 5/10/2012
#
###########################################################
# 基础全局变量
DATE=$(/bin/date +"%Y%m%d%H%M%S")
DSYM="$ARCHIVE_DSYMS_PATH/$DWARF_DSYM_FILE_NAME"
APP="$ARCHIVE_PRODUCTS_PATH/$INSTALL_PATH/$WRAPPER_NAME"
# 打包临时工作环境
BUILD_PATH="${SRCROOT}/Build"
PAYLOAD="${BUILD_PATH}/Payload"
CHANNEL_FILE="PublishChannel.txt"
# 打包后的 ipa 输出环境
TARGET_PATH="/tmp/${PROJECT_NAME}/${PLATFORM_NAME}/${DATE}"
# 发布渠道(因为默认提交到 App Store,就不需要它了)
CHANNELS=("91 Market" "163 Market" "Weiphone Cydia")
###########################################################
# 设置记录日志
LOG="/tmp/${PROJECT_NAME}_${DATE}.log"
echo "Start UMeng Publish Channel Package..." > $LOG
echo >> $LOG
echo "================================" >> $LOG
echo "APP: $APP" >> $LOG
echo "PRODUCT_NAME: $PRODUCT_NAME" >> $LOG
echo "PROJECT_NAME: $PROJECT_NAME" >> $LOG
echo "WRAPPER_NAME: $WRAPPER_NAME" >> $LOG
echo "BUILD_PATH: $BUILD_PATH" >> $LOG
echo "PAYLOAD: $PAYLOAD" >> $LOG
echo "TARGET_PATH: $TARGET_PATH" >> $LOG
echo "INSTALL_PATH: $INSTALL_PATH" >> $LOG
echo "================================" >> $LOG
echo >> $LOG
echo "1. Check Build and Target Path..." >> $LOG
# Delete Build Path
if [ ! -d ${PAYLOAD} ]; then
mkdir -p $PAYLOAD
fi
# Copy iTunesArtwork to Build Env
cp "${SRCROOT}/iTunesArtwork" "${BUILD_PATH}"
# Generating target
if [ ! -d ${TARGET_PATH} ]; then
mkdir -p $TARGET_PATH
fi
echo >> $LOG
echo "2. Copy build app to making path..." >> $LOG
cp -r "$APP" "$PAYLOAD"
echo >> $LOG
echo "3. Packaging ipa files..." >> $LOG
cd ${BUILD_PATH}
for ((i = 0; i < ${#CHANNELS[@]}; i++ ))
do
EACH_APP="${PROJECT_NAME}_${CHANNELS[$i]}.ipa"
SEARCH=" "
REPLACE="_"
NEW_APPNAME=${EACH_APP//$SEARCH/$REPLACE}
echo "${CHANNELS[$i]}\c" > "${PAYLOAD}/${WRAPPER_NAME}/${CHANNEL_FILE}"
# echo -n "${CHANNELS[$i]}" > "${PAYLOAD}/${WRAPPER_NAME}/${CHANNEL_FILE}"
ZIP=$(zip -r "${TARGET_PATH}/${NEW_APPNAME}" Payload/ iTunesArtwork)
echo " * ${NEW_APPNAME} completed." >> $LOG
done
echo >> $LOG
echo "4. Clean up..." >> $LOG
rm -rf "$BUILD_PATH"
echo >> $LOG
echo "Well Done" >> $LOG
echo "View your path: ${TARGET_PATH}/" >> $LOG
open "$TARGET_PATH"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment