diff --git a/.github/workflows/go-mod-major.sh b/.github/workflows/go-mod-major.sh new file mode 100755 index 000000000..2e09a352c --- /dev/null +++ b/.github/workflows/go-mod-major.sh @@ -0,0 +1,70 @@ +#!/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() { + cd "$1" + available_updates="$(gomajor list 2>&1 \ + | grep -v "no module versions found" \ + | awk '{ print NR ". `" $0 "`" }')" + cd - > /dev/null + + 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 <