-
Notifications
You must be signed in to change notification settings - Fork 1
/
upgrade.sh
executable file
·46 lines (36 loc) · 1.36 KB
/
upgrade.sh
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
#!/bin/bash
GREEN='\033[92m'
RESET='\033[0m'
root=$(pwd)
json=$(jq -c '.' './submodules.json')
export GOPROXY=direct
for module in $(echo $json | jq -cr '.modules[]'); do
moduleName=$(echo $module | jq -cr ".module")
dependencies=$(echo $module | jq -cr ".dependencies[]")
moduleGoPath=$(echo $json | jq -cr ".list.\"$moduleName\".goPath")
moduleRootPath=$(echo $json | jq -cr ".list.\"$moduleName\".rootPath")
moduleBranch=$(echo $json | jq -cr ".list.\"$moduleName\".branch")
echo -e "${GREEN}cd $root/$moduleGoPath${RESET}"
cd $root/$moduleGoPath
depListStr=$(echo $module | jq -r '.dependencies | join(", ")')
for dep in $dependencies; do
depUrl=$(echo $json | jq -cr ".list.\"$dep\".url")
depBranch=$(echo $json | jq -cr ".list.\"$dep\".branch")
echo -e "${GREEN}go -u get $depUrl@$depBranch${RESET}"
go get -u $depUrl@$depBranch
done
echo -e "${GREEN}cd $root/$moduleRootPath${RESET}"
cd $root/$moduleRootPath
echo -e "${GREEN}go mod tidy${RESET}"
go mod tidy
echo -e "${GREEN}git add .${RESET}"
git add .
echo -e "${GREEN}git commit -m \"'$depListStr' dependencies upgrade\"${RESET}"
git commit -m "'$depListStr' dependencies upgrade"
echo -e "${GREEN}git push${RESET}"
git push
echo -e "${GREEN}git checkout $moduleBranch${RESET}"
git checkout $moduleBranch
echo -e "${GREEN}git pull${RESET}"
git pull
done