Files
assistant-android/scripts/tinker_release_patch.sh
kehaoyuan f37a2c5b24 测试tinker回退, 没有测试成功.
获取VERSION_CODE失败 返回的是null.
跑patch脚本 gradle指定baseApk路径和脚本生成(多出两层目录)的路径不一致.
打出来的补丁包上传时提示"未匹配到可应用补丁app版本".
2017-09-25 20:56:10 +08:00

74 lines
1.9 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# *****************************************************************************
# @author CsHeng
# @2017.9.13 init
#
# 处理tinker patch包默认以最新的包作为基线包来出包
#
#
# *****************************************************************************
# get current shell absolute dir
CWD=$(cd "$(dirname "$0")"; pwd)
source ${CWD}/tinker_env.sh
# 如果git代码已经提交了目的是为了确认git commit id是能作为一个可追踪的tinkerId
cd ${CWD}
if [ -n "$(git status --porcelain)" ]; then
echo "Please make sure that you commit your code before release "
exit 0
fi
cd ${OLDPWD}
path_dir=`grep -r TINKER_BASE_APK_DIR ${GRADLE_FILE}| awk -F '=' '{print $2}'`
path_base=`echo ${path_dir} | awk -F '_' '{print $1}'`
git_sha_old=`echo ${path_dir} | awk -F '_' '{print $2}'`
git_sha_new=`git rev-parse --short HEAD`
patch_dir=${APP_TINKER_BASE}/${path_dir}/patch/${git_sha_new}
# dir exists, already patched
if [ -d "${patch_dir}" ]; then
echo "git sha has already patched, skip patch."
exit 0
else
echo "git sha has no history patch files, starting patch..."
if [ "${git_sha_new}" == "${git_sha_old}" ]; then
echo "new git sha same as old git sha, skip patch."
exit 0
fi
fi
echo ${path_dir} ${path_base} ${git_sha_old} ${git_sha_new}
echo "enabling tinker..."
# enable tinker build
sed -i.bak "s/TINKER_ENABLE\=\(.*\)/TINKER_ENABLE\=1/g" ${GRADLE_FILE}
echo ${CMD_GRADLE_SYNC}
${CMD_GRADLE_SYNC}
mkdir -p ${TINKER_BAK_APK_BASE}/${path_dir}
cp -r ${APP_TINKER_BASE}/${path_dir}/ ${TINKER_BAK_APK_BASE}/${path_dir}
echo ${CMD_GRADLE_PATCH}
${CMD_GRADLE_PATCH}
echo "copying back patch files in case that files have been cleaned..."
mkdir -p ${patch_dir}
cp -r ${PATCH_OUTPUT}/ ${patch_dir}
echo "disabling tinker"
sed -i.bak "s/TINKER_ENABLE\=\(.*\)/TINKER_ENABLE\=/g" ${GRADLE_FILE}
# remove tmp file
rm ${GRADLE_FILE}.bak
echo ${CMD_GRADLE_SYNC}
${CMD_GRADLE_SYNC}