File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22set -euo pipefail
33
4+ fix=0
5+ args=" $( getopt -o " " -l fix -- " $@ " ) "
6+ eval set -- " $args "
7+ while true ; do
8+ case " $1 " in
9+ --fix)
10+ fix=1
11+ shift
12+ ;;
13+ --)
14+ shift
15+ break
16+ ;;
17+ * )
18+ error " Unrecognized option: $1 "
19+ ;;
20+ esac
21+ done
22+
423MOD_VERSION=$( go mod edit -json | jq -r .Go)
524echo " go.mod version: $MOD_VERSION "
625STATUS=0
726
8- for wf in .github/workflows/* .yml; do
27+ if [[ $fix -eq 1 ]]; then
28+ for wf in .github/workflows/* .{yml,yaml}; do
29+ sed -i " s/go-version:.*/go-version: \" ${MOD_VERSION} \" /g" " ${wf} "
30+ done
31+ exit $STATUS
32+ fi
33+
34+ for wf in .github/workflows/* .{yml,yaml}; do
935 WF_VERSIONS=$( yq -r ' .jobs[].steps[] | select(.with["go-version"]) | .with["go-version"]' -o=tsv " $wf " | grep -v ' ^---$' || true)
1036 if [[ -z " $WF_VERSIONS " ]]; then
1137 continue
@@ -21,4 +47,8 @@ for wf in .github/workflows/*.yml; do
2147 done
2248done
2349
50+ if [[ $STATUS -eq 1 ]]; then
51+ echo " Re-run this script with --fix to automatically update workflows to match go.mod"
52+ fi
53+
2454exit $STATUS
You can’t perform that action at this time.
0 commit comments