1 Star 0 Fork 0

ronow2cn/xy-hserver

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
release.sh 1.70 KB
一键复制 编辑 原始数据 按行查看 历史
ronow2cn 提交于 2023-02-18 21:28 . scripts
#!/bin/bash
source ./env
_usage() {
echo "$0 [options] ip..."
echo "options:"
echo " -a area_dir"
echo " -d deploy-arg. can be multiple"
exit 1
}
# parse args
set -- $(getopt :a:d: $@)
while getopts a:d: opt; do
case $opt in
a)
AREA_DIR=$OPTARG
;;
d)
DEPLOY_ARGS+=" $OPTARG"
;;
?)
_usage
;;
esac
done
shift $((OPTIND - 1))
# check
[ ! $AREA_DIR ] && _usage
[ ! $1 ] && _usage
read -p "continue to release? [Yes/No]" x
[ "$x" != "Yes" ] && exit 1
# -------------------------------------
set -e
# build
go clean -cache
[ -d bin ] && mv bin bin_old
./build.sh
# retrive code rev
echo "retrieving code version ..."
BRANCH_CODE=$(git branch | grep \* | awk '{print $2}')
COMMIT=$(git log | head -1 | awk '{print $2}')
# copy version file
cp .ver/VER_${BRANCH_CODE} bin/
cat >> bin/VER_${BRANCH_CODE} << EOF
code:
$BRANCH_CODE $COMMIT
EOF
# pack
echo "packing ..."
tarfile=${PROJ_NAME}-${BRANCH_CODE}.$(date +%Y%m%d.%H%M).tar.gz
$TAR \
--exclude='**/node_modules/.bin' \
--exclude='**/node_modules/**/.bin' \
--exclude='**/node_modules/**/bin' \
-hczf $tarfile bin
# upload
for IP in $@; do
echo "uploading ($IP) ..."
scp $tarfile game@$IP:$WORK_DIR/$AREA_DIR
done
# clean up
echo "cleaning up ..."
rm $tarfile
rm -rf bin
[ -d bin_old ] && mv bin_old bin
# exec deploy.sh if there's any in remote
for IP in $@; do
echo "deploying ($IP) ..."
ssh game@$IP "
if [ -x $WORK_DIR/$AREA_DIR/dev_auto_update.sh ]; then
cd $WORK_DIR/$AREA_DIR
./dev_auto_update.sh $tarfile $DEPLOY_ARGS
fi
"
done
# done
echo -e "\033[32mDone.\033[0m"
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ronow2cn/xy-hserver.git
git@gitee.com:ronow2cn/xy-hserver.git
ronow2cn
xy-hserver
xy-hserver
master

搜索帮助