代码拉取完成,页面将自动刷新
同步操作将从 Discuz/discuz_build_script 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/bin/bash -e
if [ "$#" -lt 1 ] || [ "$#" -gt 2 ]; then
echo "Illegal number of parameters"
exit 1
fi
TAG=$1
DRY_RUN=""
[ "$#" -eq 2 ] && DRY_RUN=$2
BASE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cd $BASE
echo "---- Build Discuz Q and Commit to Git Repo -----------------------------"
[ "$DRY_RUN" = "-n" ] && echo "Dry run, no changes will be pushed to remote"
# 业务代码仓库
DISCUZ_REPO=""
# 编译后的用户端前端代码仓库
DISCUZ_WEB=""
# 编译后的管理端前端代码仓库
DISCUZ_ADMIN=""
function fix_composer {
cd $BASE/dz_temp
echo "---- fixing composer.json"
cat composer.json | jq ".require.\"discuz/core\" = \"$TAG\"" | jq '.repositories = [{ "type": "composer", "url": "https://cloud.discuz.chat" }]' > composer-fixed.json
mv composer-fixed.json composer.json
}
function mkdir_public {
cd $BASE/dz_temp
echo "---- mkdir public_1"
mkdir public_1
cd $BASE/dz_temp/public_1
echo 1 > skin.conf
echo "---- mkdir public_2"
cd $BASE/dz_temp
mkdir public_2
cd $BASE/dz_temp/public_2
echo 2 > skin.conf
}
function build_admin {
cd $BASE/dz_temp
echo "---- building admin"
docker run --rm -i -v $PWD:/usr/src/app node:12 /bin/bash -c "cd /usr/src/app/resources/frame && npm install && npm run-script build-admin"
if [ $? -eq 0 ]; then
echo "---- npm build successfully"
echo "---- removing resources/frame/node_modules"
rm -rf resources/frame/node_modules
else
echo "---- npm build failed"
exit 1
fi
cp $BASE/dz_temp/public/admin.html $BASE/dz_temp/public_1/
cp -r $BASE/dz_temp/public/static-admin $BASE/dz_temp/public_1/
}
function build_admin_pay {
cd $BASE/dz_temp
echo "---- building admin pay"
docker run --rm -i -v $PWD:/usr/src/app node:12 /bin/bash -c "cd /usr/src/app/resources/frame && npm install && npm run-script build-admin:pay"
if [ $? -eq 0 ]; then
echo "---- npm build successfully"
echo "---- removing resources/frame/node_modules"
rm -rf resources/frame/node_modules
else
echo "---- npm build failed"
exit 1
fi
cp -r $BASE/dz_temp/public_pay/* $BASE/dz_temp/public_2
rm -rf $BASE/dz_temp/public_pay
}
function commit_all {
cd $BASE/dz_temp
echo "---- commit build result"
sed -i '/\/public\/static/d' .gitignore
sed -i '/\/public\/index\.html/d' .gitignore
sed -i '/\/public\/admin\.html/d' .gitignore
sed -i '/\/app\/Console\/Commands\/Upgrades\//d' .gitignore
rm -f app/Console/Commands/Upgrades/.gitignore
rm -rf .github
git add --all
git commit -m "auto vue build by bot"
}
function retag_repo {
cd $BASE/dz_temp
echo "---- retag the repo"
git tag -d $TAG
git tag $TAG
}
function push_to_remote {
cd $BASE/dz_temp
if [ ! "$DRY_RUN" = "-n" ]; then
echo "---- push to build repo"
#git remote add build git@git.code.oa.com:discuzq-build2/Discuz.git
git remote add build ssh://git@gitee.com:22/mulanhao/Discuz.git
git push build $TAG -f
else
echo "---- Dry run mode, do not actually push"
fi
}
function checkout_uniapp {
cd $BASE
echo "---- removing uniapp_temp"
rm -rf $BASE/uniapp_temp
echo "---- clone new copy of uniapp to uniapp_temp"
git clone $UNIAPP_REPO uniapp_temp
}
function checkout_discuz {
cd $BASE
echo "---- removing dz_temp"
rm -rf $BASE/dz_temp
echo "---- clone new copy of Discuz to dz_temp"
git clone $DISCUZ_REPO dz_temp
}
function checkout_tag_as_branch {
cd $1
echo "---- checking out tag $TAG as branch br_$TAG under $1"
git checkout -b br_$TAG $TAG
}
function build_uniapp {
cd $BASE/uniapp_temp
echo "---- building uniapp"
docker run --rm -it -v $PWD:/usr/src/app node:12 /bin/bash -c "cd /usr/src/app && npm --no-update-notifier install && npm --no-update-notifier run-script build:h5"
}
function build_web {
cd $BASE/web_temp
echo "---- building web"
docker run --rm -it -v $PWD:/usr/src/app node:12 /bin/bash -c "cd /usr/src/app && npm --no-update-notifier install && npm --no-update-notifier run generate"
}
function checkout_web_build {
cd $BASE
echo "---- removing web_temp_builded"
rm -rf $BASE/web_temp_builded
echo "---- clone new copy of discuz-dist-pc to web_temp_builded"
git clone $DISCUZ_WEB web_temp_builded
}
function checkout_web_pay_build {
cd $BASE
echo "---- removing web_pay_temp_builded"
rm -rf $BASE/web_pay_temp_builded
echo "---- clone new copy of discuz-dist-pc-pay to web_pay_temp_builded"
git clone $DISCUZ_DIST_PC_PLAY web_pay_temp_builded
}
function checkout_uniapp_build {
cd $BASE
echo "---- removing uniapp_temp_builded"
rm -rf $BASE/uniapp_temp_builded
echo "---- clone new copy of discuz-dist-h5 to uniapp_temp_builded"
git clone $DISCUZ_DIST_UNIAPP uniapp_temp_builded
}
function checkout_uniapp_pay_build {
cd $BASE
echo "---- removing uniapp_pay_temp_builded"
rm -rf $BASE/uniapp_pay_temp_builded
echo "---- clone new copy of discuz-dist-h5 to uniapp_pay_temp_builded"
git clone $DISCUZ_DIST_UNIAPP_PLAY uniapp_pay_temp_builded
}
function checkout_admin_build {
cd $BASE
echo "---- removing web_admin_temp_builded"
rm -rf $BASE/web_admin_temp_builded
echo "---- clone new copy of discuz-dist-h5 to web_admin_temp_builded"
git clone $DISCUZ_ADMIN web_admin_temp_builded
}
function copy_uniapp_to_discuz {
echo "---- copying uniapp h5 result to discuz folder"
cd $BASE/uniapp_temp_builded
rm -rf .git .github
cp -r * $BASE/dz_temp/public
cp -r * $BASE/dz_temp/public_1
}
function copy_uniapp_pay_to_discuz {
echo "---- copying uniapp h5 pay result to discuz folder"
cd $BASE/uniapp_pay_temp_builded
rm -rf .git .github
cp -r * $BASE/dz_temp/public_2
}
function copy_web_to_discuz {
echo "---- copying web result to discuz folder"
cd $BASE/web_temp_builded
rm -rf .git .github
cp -r * $BASE/dz_temp/public/
}
function copy_web_pay_to_discuz {
echo "---- copying web pay result to discuz folder"
cd $BASE/web_pay_temp_builded
rm -rf .git .github
cp -r * $BASE/dz_temp/public_2/
}
function copy_admin_to_discuz {
echo "---- copying admin result to discuz folder"
cd $BASE/web_admin_temp_builded
rm -rf .git .github
cp -r * $BASE/dz_temp/public/
}
function copy_upgrade_commands {
cd $BASE
echo "---- copying upgrade commands"
if [ ! -d $BASE"/dz_temp/app/Console/Commands/Upgrades/" ];
then
mkdir $BASE/dz_temp/app/Console/Commands/Upgrades/
fi
cp upgrade-commands/* dz_temp/app/Console/Commands/Upgrades/
}
checkout_web_build
checkout_tag_as_branch $BASE/web_temp_builded
checkout_admin_build
checkout_tag_as_branch $BASE/web_admin_temp_builded
checkout_discuz
checkout_tag_as_branch $BASE/dz_temp
copy_upgrade_commands
copy_web_to_discuz
copy_admin_to_discuz
commit_all
retag_repo
push_to_remote
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。