File tree Expand file tree Collapse file tree 1 file changed +10
-18
lines changed Expand file tree Collapse file tree 1 file changed +10
-18
lines changed Original file line number Diff line number Diff line change @@ -3,30 +3,22 @@ set -euo pipefail
3
3
4
4
MOD_VERSION=$( go mod edit -json | jq -r .Go)
5
5
echo " go.mod version: $MOD_VERSION "
6
+ STATUS=0
6
7
7
8
for wf in .github/workflows/* .yml; do
8
- echo " Checking $wf ..."
9
-
10
9
WF_VERSIONS=$( yq -r ' .jobs[].steps[] | select(.with["go-version"]) | .with["go-version"]' -o=tsv " $wf " | grep -v ' ^---$' || true)
11
- if [ -z " $WF_VERSIONS " ]; then
12
- echo " ℹ️ No go-version found in $wf (skipped)"
10
+ if [[ -z " $WF_VERSIONS " ]]; then
13
11
continue
14
12
fi
15
13
16
14
UNIQUE_WF_VERSIONS=$( echo " $WF_VERSIONS " | sort -u)
17
- if [ " $( echo " $UNIQUE_WF_VERSIONS " | wc -l) " -ne 1 ]; then
18
- echo " ❌ Multiple Go versions found in $wf :"
19
- echo " $UNIQUE_WF_VERSIONS "
20
- exit 1
21
- fi
22
-
23
- # At this point there's only one unique Go version
24
- if [ " $UNIQUE_WF_VERSIONS " != " $MOD_VERSION " ]; then
25
- echo " ❌ Mismatch in $wf : go.mod=$MOD_VERSION but workflow uses $UNIQUE_WF_VERSIONS "
26
- exit 1
27
- fi
28
-
29
- echo " ✅ $wf matches go.mod ($MOD_VERSION )"
15
+ for ver in $UNIQUE_WF_VERSIONS ; do
16
+ if [[ " ${ver} " != " $MOD_VERSION " ]]; then
17
+ STATUS=1
18
+ echo " ❌ $wf : go.mod=$MOD_VERSION but workflow uses $( tr ' \n' ' ' <<< " $UNIQUE_WF_VERSIONS" ) "
19
+ continue
20
+ fi
21
+ done
30
22
done
31
23
32
- echo " ✅ All workflows consistent with go.mod ( $MOD_VERSION ) "
24
+ exit $STATUS
You can’t perform that action at this time.
0 commit comments