2021-12-12 22:07:04 +08:00
|
|
|
|
#!/bin/bash
|
2022-03-09 22:19:22 +08:00
|
|
|
|
#
|
|
|
|
|
# The MIT License (MIT)
|
|
|
|
|
#
|
|
|
|
|
# Copyright (c) 2019 Code Technology Studio
|
|
|
|
|
#
|
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
|
# this software and associated documentation files (the "Software"), to deal in
|
|
|
|
|
# the Software without restriction, including without limitation the rights to
|
|
|
|
|
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
|
# the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
|
# subject to the following conditions:
|
|
|
|
|
#
|
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
# copies or substantial portions of the Software.
|
|
|
|
|
#
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
|
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
|
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
#
|
|
|
|
|
|
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"
|
|
|
|
|
|
2023-04-04 18:22:28 +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
|
|
|
|
| |__| | |_) | (_) | | | | | |
|
|
|
|
|
\____/| .__/ \___/|_| |_| |_|
|
|
|
|
|
| |
|
|
|
|
|
|_|
|
|
|
|
|
|
|
|
|
|
➜ Jpom \ (•◡•) / (v$new_version)
|
|
|
|
|
|
|
|
|
|
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"
|