Files
assistant-android/scripts/tinker_release_patch.sh
2017-09-15 15:24:44 +08:00

71 lines
2.0 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)
GRADLE_FILE=${CWD}/../gradle.properties
BAK_APK_DIR=${CWD}/../app/build/bakApk/
PATCH_OUTPUT=${BAK_APK_DIR}/../outputs/patch/
PATCH_BACKUP=${CWD}/../patch/
# 如果git代码已经提交了目的是为了确认git commit id是能作为一个可追踪的tinkerId
status=`cd ${CWD} && git status | grep up-to-date | wc -l && cd ${OLDPWD}`
if [ ${status} -eq 0 ]; then
echo "Please make sure that you commit your code before release "
exit 0
fi
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_new=`git rev-parse --short HEAD`
git_sha_old=`echo ${path_dir} | awk -F '_' '{print $2}'`
echo ${path_dir} ${path_base} ${git_sha_old} ${git_sha_new}
if [ "${git_sha_new}" == "${git_sha_old}" ]; then
echo "new git sha same as old git sha, skip patch."
exit 0
fi
echo "enabling tinker..."
# enable tinker build
sed -i.bak "s/TINKER_ENABLE\=\(.*\)/TINKER_ENABLE\=1/g" ${GRADLE_FILE}
echo "recompiling gradle scripts..."
${CWD}/../gradlew --recompile-scripts
mkdir -p ${BAK_APK_DIR}/${path_dir}
cp -r ${PATCH_BACKUP}/${path_dir}/ ${BAK_APK_DIR}/${path_dir}
echo "releasing patch... gradle buildAllFlavorsTinkerPatchRelease..."
${CWD}/../gradlew buildAllFlavorsTinkerPatchRelease --parallel
echo "copying back patch files in case that files have been cleaned..."
dest_dir=${PATCH_BACKUP}/${path_dir}/${git_sha_new}
mkdir -p ${dest_dir}
cp -r ${PATCH_OUTPUT}/ ${dest_dir}
echo "disabling tinker"
sed -i.bak "s/TINKER_ENABLE\=\(.*\)/TINKER_ENABLE\=/g" ${GRADLE_FILE}
# remove tmp file
rm ${GRADLE_FILE}.bak
echo "recompiling gradle scripts..."
${CWD}/../gradlew --recompile-scripts