Jpom/script/replaceVersion.sh

94 lines
3.0 KiB
Bash
Raw Normal View History

#!/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.
#
#-----------------------------------------------------------
# 此脚本用于每次升级时替换相应位置的版本号
#-----------------------------------------------------------
set -o errexit
2022-12-08 15:23:03 +08:00
current_path=$(pwd)
case "$(uname)" in
Linux)
bin_abs_path=$(readlink -f $(dirname $0))
;;
*)
bin_abs_path=$(
cd $(dirname $0)
pwd
)
;;
2022-09-06 10:20:31 +08:00
esac
base=${bin_abs_path}/../
2022-09-07 10:11:54 +08:00
echo "当前路径:${current_path} 脚本路径:${bin_abs_path}"
2022-12-08 15:23:03 +08:00
if [ -n "$1" ]; then
new_version="$1"
old_version=$(cat ${base}/docs/version.txt)
echo "$old_version 替换为新版本 $new_version"
else
2022-12-08 15:23:03 +08:00
# 参数错误,退出
echo "ERROR: 请指定新版本!"
exit
fi
if [ ! -n "$old_version" ]; then
2022-12-08 15:23:03 +08:00
echo "ERROR: 旧版本不存在,请确认 /docs/version.txt 中信息正确"
exit
fi
# 替换所有模块pom.xml中的版本
2022-09-07 10:11:54 +08:00
cd ${base} && mvn versions:set -DnewVersion=$1
2022-10-20 14:49:58 +08:00
echo "替换配置文件版本号 $new_version"
if [ -f "$base/.env" ]; then
# 替换 docker 中的版本
sed -i.bak "s/${old_version}/${new_version}/g" $base/.env
fi
2021-12-15 13:12:56 +08:00
# 替换 Dockerfile 中的版本
2022-09-06 10:20:31 +08:00
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
2022-03-04 08:37:25 +08:00
# logo
2022-12-08 15:23:03 +08:00
sed -i.bak "s/${old_version}/${new_version}/g" $base/modules/common/src/main/resources/banner.txt
2022-03-04 08:37:25 +08:00
2022-01-11 17:36:01 +08:00
# vue version
2022-09-06 10:20:31 +08:00
sed -i.bak "s/${old_version}/${new_version}/g" $base/web-vue/package.json
2022-01-11 17:36:01 +08:00
2022-03-10 23:22:12 +08:00
# release-sha1sum.sh
2022-09-06 10:20:31 +08:00
sed -i.bak "s/${old_version}/${new_version}/g" $base/script/release-sha1sum.sh
2022-03-10 23:22:12 +08:00
2022-05-28 19:53:13 +08:00
# gitee go
2022-09-06 10:20:31 +08:00
sed -i.bak "s/${old_version}/${new_version}/g" $base/.workflow/MasterPipeline.yml
2022-05-28 19:53:13 +08:00
# 保留新版本号
2022-12-08 15:23:03 +08:00
echo "$new_version" >$base/docs/version.txt
2022-10-20 14:49:58 +08:00
echo "版本号替换成功 $new_version"