2021-12-12 22:07:04 +08:00
#!/bin/bash
2022-03-09 22:19:22 +08:00
#
2024-02-29 21:35:12 +08:00
# Copyright (c) 2019 Of Him Code Technology Studio
2024-02-29 14:10:24 +08:00
# Jpom is licensed under Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
# http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.
2022-03-09 22:19:22 +08:00
#
2021-12-12 22:07:04 +08:00
#-----------------------------------------------------------
# 此脚本用于每次升级时替换相应位置的版本号
#-----------------------------------------------------------
set -o errexit
2022-12-08 15:23:03 +08:00
current_path = $( pwd )
case " $( uname) " in
Linux)
2023-04-03 17:31:22 +08:00
bin_abs_path = $( readlink -f " $( dirname " $0 " ) " )
; ;
2022-12-08 15:23:03 +08:00
*)
2023-04-03 17:31:22 +08:00
bin_abs_path = $(
cd " $( dirname " $0 " ) "
pwd
)
; ;
2022-09-06 10:20:31 +08:00
esac
base = ${ bin_abs_path } /../
2021-12-12 22:07:04 +08:00
2023-03-21 20:14:07 +08:00
tag = " $2 "
2023-04-04 18:22:28 +08:00
echo " 当前路径: ${ current_path } 脚本路径: ${ bin_abs_path } $tag "
2021-12-12 22:07:04 +08:00
2022-12-08 15:23:03 +08:00
if [ -n " $1 " ] ; then
2023-04-03 17:31:22 +08:00
new_version = " $1 "
old_version = $( cat " ${ base } /script/tag. $tag .txt " )
echo " $old_version 替换为新版本 $new_version "
2021-12-12 22:07:04 +08:00
else
2023-04-03 17:31:22 +08:00
# 参数错误,退出
2023-04-04 18:22:28 +08:00
echo "ERROR: 请指定新版本!" 2>& 2
exit 1
2021-12-12 22:07:04 +08:00
fi
if [ ! -n " $old_version " ] ; then
2023-04-04 18:22:28 +08:00
echo " ERROR: 旧版本不存在,请确认 /script/tag. $tag .txt 中信息正确 " 2>& 2
exit 1
2021-12-12 22:07:04 +08:00
fi
2022-10-20 14:49:58 +08:00
echo " 替换配置文件版本号 $new_version "
2024-03-01 14:06:29 +08:00
if [ " $tag " = = "release" ] ; then
2023-04-03 17:31:22 +08:00
# 替换 Dockerfile 中的版本
sed -i.bak " s/ ${ old_version } / ${ new_version } /g " " $base /modules/server/Dockerfile "
sed -i.bak " s/ ${ old_version } / ${ new_version } /g " " $base /modules/agent/Dockerfile "
sed -i.bak " s/ ${ old_version } / ${ new_version } /g " " $base /script/docker.sh "
sed -i.bak " s/ ${ old_version } / ${ new_version } /g " " $base /modules/server/DockerfileRelease "
2023-08-19 13:24:29 +08:00
sed -i.bak " s/ ${ old_version } / ${ new_version } /g " " $base /modules/server/DockerfileReleaseJdk17 "
2023-04-03 17:31:22 +08:00
# vue version
sed -i.bak " s/ ${ old_version } / ${ new_version } /g " " $base /web-vue/package.json "
# 替换 docker 中的版本
sed -i.bak " s/ ${ old_version } / ${ new_version } /g " " $base /.env "
# gitee go
sed -i.bak " s/ ${ old_version } / ${ new_version } /g " " $base /.workflow/MasterPipeline.yml "
2023-03-21 21:44:32 +08:00
elif [ " $tag " = = "beta" ] ; then
2023-04-03 17:31:22 +08:00
sed -i.bak " s/ ${ old_version } / ${ new_version } /g " " $base /modules/server/DockerfileBeta "
2023-08-19 13:24:29 +08:00
sed -i.bak " s/ ${ old_version } / ${ new_version } /g " " $base /modules/server/DockerfileBetaJdk17 "
2023-03-21 21:44:32 +08:00
else
2023-04-04 18:22:28 +08:00
echo " 不支持的模式 $tag " 2>& 2
exit 2
2022-12-09 15:13:01 +08:00
fi
2021-12-15 13:12:56 +08:00
2023-03-21 21:44:32 +08:00
# 替换所有模块pom.xml中的版本
2023-04-04 18:22:28 +08:00
cd " ${ base } " && mvn -s " $base /script/settings.xml " versions:set -DnewVersion= $new_version
2023-03-21 21:44:32 +08:00
# 替换 docker 中的版本
sed -i.bak " s/ ${ old_version } / ${ new_version } /g " " $base /env- $tag .env "
2021-12-12 22:07:04 +08:00
2022-03-04 08:37:25 +08:00
# logo
2023-03-21 21:44:32 +08:00
cat >" $base /modules/common/src/main/resources/banner.txt " <<EOF
_
| |
| | _ __ ___ _ __ ___
2023-03-27 16:57:20 +08:00
_ | | '_ \ / _ \| ' _ \` _ \\
2023-03-21 21:44:32 +08:00
| | __| | | _) | ( _) | | | | | |
\_ ___/| .__/ \_ __/| _| | _| | _|
| |
| _|
2024-03-01 14:36:25 +08:00
➜ Jpom is licensed under Mulan PSL v2.
➜ \ ( •◡•) / ( v$new_version )
2023-03-21 21:44:32 +08:00
EOF
2022-03-04 08:37:25 +08:00
2021-12-12 22:07:04 +08:00
# 保留新版本号
2023-03-21 20:14:07 +08:00
echo " $new_version " >" ${ base } /script/tag. $tag .txt "
2022-10-20 14:49:58 +08:00
echo " 版本号替换成功 $new_version "