Skip to content

Commit

Permalink
Update bump-k8s-dep.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
XudongLiuHarold authored Mar 7, 2024
1 parent b64b318 commit 6ce92a8
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions hack/bump-k8s-dep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,35 @@ set -o errexit
set -o nounset
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")

check_and_bump_dependency() {
dep=$1
current_version=$(go list -m -f '{{.Version}}' "${dep}")
# latest_stable_version=$(go list -m -u -json ${dep} | jq -r .Version)
latest_version=$(go list -m -versions -json "${dep}" | jq -r '.Versions[-1]')
# latest_stable_version=$(go list -m -u -json ${dep} | jq -r .Version)

# filter out the alpha release
if [[ $latest_version =~ alpha\.([0-9]+)$ ]]; then
echo "Skip auto bump for alpha release: [$dep@$current_version]"
return
fi

echo "Current $dep version: $current_version"
echo "Latest $dep version: $latest_version"

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

# Loop through the list of dependencies
for dep in "${dependencies[@]}"; do
check_and_bump_dependency "$dep"
check_and_bump_dependency "$dep"
done

go mod tidy

0 comments on commit 6ce92a8

Please sign in to comment.