Skip to content

Commit

Permalink
Update bump-k8s-dep.sh
Browse files Browse the repository at this point in the history
fix bump-k8s-dep.sh bug
  • Loading branch information
XudongLiuHarold authored Mar 5, 2024
1 parent 314670f commit 137ab2b
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions hack/bump-k8s-dep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ set -o pipefail

dependencies=("k8s.io/api" "k8s.io/client-go" "k8s.io/cloud-provider" "k8s.io/apimachinery" "k8s.io/code-generator" "k8s.io/component-base" "k8s.io/klog/v2")

compare_versions() {
version1=$1
version2=$2

if [[ $(echo -e "$version1\n$version2" | sort -V | tail -n 1) == "$version1" ]]; then
return 0
else
return 1
fi
}

check_and_bump_dependency() {
dep=$1
current_version=$(go list -m -f '{{.Version}}' "${dep}")
Expand All @@ -45,15 +34,12 @@ check_and_bump_dependency() {
echo "Current $dep version: $current_version"
echo "Latest $dep version: $latest_version"

compare_versions "$current_version" "$latest_version"
result=$?

# Bump the version if needed
if [ $result -eq 1 ]; then
echo "Updating $dep to the $latest_version..."
go get -u k8s.io/api@"${latest_version}"
if [ "$current_version" == "$latest_version" ]; then
echo "$dep@$current_version is already up to date."
else
echo "$dep is already up to date."
echo "Updating $dep to the $latest_version..."
go get -u "${dep}"@"${latest_version}"
fi
}

Expand All @@ -62,4 +48,4 @@ for dep in "${dependencies[@]}"; do
check_and_bump_dependency "$dep"
done

go mod tidy
go mod tidy

0 comments on commit 137ab2b

Please sign in to comment.