1
- #! /bin/sh -x
1
+ #! /bin/sh
2
2
3
3
# Copyright 2023 The Kubernetes Authors.
4
4
#
27
27
# 1. Login with "gh auth login"
28
28
# 2. Copy this script to the kubernetes-csi directory (one directory above the
29
29
# repos)
30
- # 3. Update the repos and branches
30
+ # 3. Update the repos and master branch so locally it has the latest upstream
31
+ # change
31
32
# 4. Set environment variables
32
33
# 5. Run script from the kubernetes-csi directory
33
34
#
34
35
# Caveats:
35
36
# - This script doesn't handle interface incompatibility of updates.
37
+ # You need to resolve interface incompatibility case by case. The
38
+ # most frequent case is to update the interface(new parameters,
39
+ # name change of the method, etc.)in the sidecar repo and make sure
40
+ # the build and test pass.
36
41
37
42
38
- die () {
39
- echo >&2 " $@ "
40
- exit 1
41
- }
43
+ set -e
44
+ set -x
42
45
43
46
MAX_RETRY=10
44
47
@@ -56,18 +59,18 @@ while getopts ":u:v:" option; do
56
59
done
57
60
58
61
# Only need to do this once
59
- gh auth login || die " gh auth login failed "
62
+ gh auth login
60
63
61
64
while read -r repo branches; do
62
65
if [ " $repo " != " #" ]; then
63
66
(
64
- cd " $repo " || die " $repo : does not exit "
65
- git fetch origin || die " $repo : git fetch "
67
+ cd " $repo "
68
+ git fetch origin
66
69
for i in $branches ; do
67
70
if [ " $( git rev-parse --verify " module-update-$i " 2> /dev/null) " ]; then
68
71
git checkout master && git branch -d " module-update-$i "
69
72
fi
70
- git checkout -B " module-update-$i " " origin/$i " || die " $repo : $i checkout "
73
+ git checkout -B " module-update-$i " " origin/$i "
71
74
rm -rf .git/MERGE*
72
75
if ! git subtree pull --squash --prefix=release-tools https://github.com/kubernetes-csi/csi-release-tools.git master; then
73
76
# Sometimes "--squash" leads to merge conflicts. Because we know that "release-tools"
@@ -76,11 +79,11 @@ while read -r repo branches; do
76
79
if [ -e .git/MERGE_MSG ] && [ -e .git/FETCH_HEAD ] && grep -q " ^# Conflict" .git/MERGE_MSG; then
77
80
rm -rf release-tools
78
81
mkdir release-tools
79
- git archive FETCH_HEAD | tar -C release-tools -xf - || die " failed to re-create release-tools from FETCH_HEAD "
80
- git add release-tools || die " add release-tools "
81
- git commit --file=.git/MERGE_MSG || die " commit squashed release-tools "
82
+ git archive FETCH_HEAD | tar -C release-tools -xf -
83
+ git add release-tools
84
+ git commit --file=.git/MERGE_MSG
82
85
else
83
- die " git subtree pull --squash failed, cannot reover. "
86
+ exit 1
84
87
fi
85
88
fi
86
89
RETRY=0
@@ -89,12 +92,12 @@ while read -r repo branches; do
89
92
RETRY=$(( RETRY+ 1 ))
90
93
go mod tidy && go mod vendor && go mod tidy
91
94
done
92
- go mod tidy && go mod vendor && go mod tidy || die " last go mod vendor && go mod tidy failed "
93
- git add --all || die " git add -all failed "
94
- git commit -m " Update dependency go modules for k8s v$v " || die " commit update modules "
95
- git remote set-url origin " https://github.com/$username /$repo .git" || die " git remote set-url failed "
96
- make test || die " $repo : $i make test "
97
- git push origin " module-update-$i " --force || die " origin:module-update- $i push failed - probably there is already an unmerged branch and pending PR "
95
+ go mod tidy && go mod vendor && go mod tidy
96
+ git add --all
97
+ git commit -m " Update dependency go modules for k8s v$v "
98
+ git remote set-url origin " https://github.com/$username /$repo .git"
99
+ make test
100
+ git push origin " module-update-$i " --force
98
101
# Create PR
99
102
prbody=$( cat << EOF
100
103
Ran kubernetes-csi/csi-release-tools go-get-kubernetes.sh -p ${v} .
107
110
)
108
111
gh pr create --title=" Update dependency go modules for k8s v$v " --body " $prbody " --head " $username :module-update-master" --base " master" --repo=" kubernetes-csi/$repo "
109
112
done
110
- ) || die " failed "
113
+ )
111
114
fi
112
115
done << EOF
113
116
csi-driver-host-path master
0 commit comments