Skip to content

Commit fa7ae47

Browse files
committed
update circleci check
1 parent 812496f commit fa7ae47

File tree

1 file changed

+32
-5
lines changed

1 file changed

+32
-5
lines changed

.circleci/config.yml

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,39 @@ commands:
9090
check-go-version:
9191
steps:
9292
- run: |
93-
v=`go version | { read _ _ v _; echo ${v#go}; }`
94-
if [[ $v != `cat GO_VERSION_MIN` ]]; then
95-
echo "GO_VERSION_MIN file does not match the go version being used."
96-
echo "Please update image to cimg/go:`cat GO_VERSION_MIN` or update GO_VERSION_MIN to $v."
97-
exit 1
93+
v=$(go version | { read _ _ v _; echo ${v#go}; })
94+
go_min=$(cat GO_VERSION_MIN | tr -d ' \n') # Remove spaces/newlines
95+
96+
# Extract major, minor, and full versions
97+
v_major=$(echo "$v" | cut -d. -f1)
98+
v_major_minor=$(echo "$v" | cut -d. -f1,2)
99+
v_full=$(echo "$v" | cut -d. -f1,2,3)
100+
101+
go_min_major=$(echo "$go_min" | cut -d. -f1)
102+
go_min_major_minor=$(echo "$go_min" | cut -d. -f1,2)
103+
go_min_full=$(echo "$go_min" | cut -d. -f1,2,3)
104+
105+
# Ensure major version is allowed
106+
if [[ "$v_major" != "1" && "$v_major" != "23" && "$v_major" != "6" ]]; then
107+
echo "Go version mismatch! Allowed major versions: 1, 23, 6, but found Go $v."
108+
exit 1
109+
fi
110+
111+
# If GO_VERSION_MIN specifies a patch version, check full match
112+
if [[ "$go_min" == *.*.* ]]; then
113+
if [[ "$v_full" != "$go_min_full" ]]; then
114+
echo "Go version mismatch! Expected Go $go_min but found $v."
115+
exit 1
98116
fi
117+
# If GO_VERSION_MIN specifies only major.minor, check that exactly
118+
elif [[ "$go_min" == *.* ]]; then
119+
if [[ "$v_major_minor" != "$go_min_major_minor" ]]; then
120+
echo "Go version mismatch! Expected Go $go_min but found $v."
121+
exit 1
122+
fi
123+
fi
124+
125+
echo "Go version matches: $v"
99126
100127
jobs:
101128
build-debug:

0 commit comments

Comments
 (0)