From c590ca47e60567ae103ddecc466a343f9f7ce21e Mon Sep 17 00:00:00 2001 From: Alvar Penning Date: Fri, 22 Mar 2024 11:28:33 +0100 Subject: [PATCH] GitHub Actions: Notify Go Module Major Version Updates When Go modules mature and their major version has exceeded one, the module path requires a version suffix, such as "/v2"[0]. Unfortunately, the Dependabot is unable to detect such a Go module major version bump for suffixed major versions[1], resulting in stalling dependencies. By introducing another GitHub Actions Workflow utilizing gomajor[2], those major version updates for Go modules can be identified. As a scheduled workflow, running each Monday morning, it will either create or update an open GitHub issue with all currently available major version updates for referenced Go modules. [0]: https://go.dev/ref/mod#major-version-suffixes [1]: https://github.com/dependabot/dependabot-core/issues/2213 [2]: https://github.com/icholy/gomajor --- .github/workflows/go-mod-major.sh | 70 ++++++++++++++++++++++++++++++ .github/workflows/go-mod-major.yml | 25 +++++++++++ 2 files changed, 95 insertions(+) create mode 100755 .github/workflows/go-mod-major.sh create mode 100644 .github/workflows/go-mod-major.yml 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 <