forked from cloudwego/eino-ext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupgrade_cloudwego_eino.sh
More file actions
executable file
·56 lines (43 loc) · 1.14 KB
/
upgrade_cloudwego_eino.sh
File metadata and controls
executable file
·56 lines (43 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# 依赖包名称
DEPENDENCY="github.com/cloudwego/eino"
# 指定的版本号或分支(如果未提供,则更新到最新版本)
VERSION=${1:-latest}
# 红色加粗字体的
RED_BOLD="\033[1;31m"
# 重置终端颜色和样式
RESET="\033[0m"
# 用于查找所有包含 go.mod 的子模块
find_submodules() {
find . -type f -name "go.mod" -exec dirname {} \;
}
# 更新指定依赖到最新版本
update_dependency() {
local mod_path=$1
echo ""
echo -e "${RED_BOLD}Updating dependency ${DEPENDENCY}@${VERSION} in module $mod_path...${RESET}"
echo ""
# 切换到子模块目录
cd "$mod_path" || exit
# 更新依赖到最新版本
go get -u "${DEPENDENCY}@${VERSION}"
# 整理 go.mod 和 go.sum 文件
go mod tidy
# 切换回原始目录
cd - >/dev/null || exit
}
# 遍历所有子模块并更新依赖
update_all_submodules() {
submodules=$(find_submodules)
if [ -z "$submodules" ]; then
echo -e "${RED_BOLD}No Go modules found.${RESET}"
exit 1
fi
for mod in $submodules; do
update_dependency "$mod"
done
}
# 开始更新
update_all_submodules
echo ""
echo -e "Dependency update completed."