diff --git a/.github/workflows/go-mod-major.sh b/.github/workflows/go-mod-major.sh new file mode 100755 index 000000000..d6e4f3e57 --- /dev/null +++ b/.github/workflows/go-mod-major.sh @@ -0,0 +1,68 @@ +#!/bin/sh + +# A GitHub issue with this title and those labels (might be just one) +# will be created or, if it already exists and is open, will be reused. +GH_ISSUE_TITLE="Go Module Major Version Updates" +GH_ISSUE_LABELS="dependencies" + +set -eu + +# UPDATE_MSG will be altered from within check_updates() +UPDATE_MSG="" + +# check_updates DIR check if any major updates are within DIR. +# Found updates are being added to UPDATE_MSG +check_updates() { + available_updates="$(gomajor list -major -dir "$1" 2>&1 \ + | grep -v "no module versions found" \ + | awk '{ print NR ". `" $0 "`" }')" + + if [ -z "$available_updates" ]; then + echo "Nothing to do in $1" + return + fi + + echo "Found $(echo "$available_updates" | wc -l) updates in $1" + UPDATE_MSG="$(cat <