diff --git a/.github/workflows/scripts/update-golang.sh b/.github/workflows/scripts/update-golang.sh new file mode 100755 index 0000000000..7bb794db2b --- /dev/null +++ b/.github/workflows/scripts/update-golang.sh @@ -0,0 +1,47 @@ +#!/bin/bash +set -e + +VERSION='' + +while getopts v: flag +do + case "${flag}" in + v) VERSION=${OPTARG};; + *) exit 1;; + esac +done + +if [ -z "$VERSION" ]; then + echo "Error: VERSION is required" + echo "Usage: $0 -v " + exit 1 +fi + +echo "Bumping Go version to $VERSION..." + +# Determine the OS and set the sed function accordingly +if [[ "$OSTYPE" == "darwin"* ]]; then + # macOS + sed_inplace() { + sed -i '' "$@" + } +else + # Linux + sed_inplace() { + sed -i "$@" + } +fi + +# Find all go.mod files +echo "Finding all go.mod files..." +GO_MOD_FILES=$(find . -name "go.mod" -type f) + +# Update all go.mod files +echo "Updating all go.mod files..." +while IFS= read -r file; do + sed_inplace -E "s/^go [0-9]+\.[0-9]+.*/go $VERSION/g" "$file" +done <<< "$GO_MOD_FILES" + +echo "" +echo "✓ Successfully bumped golang version to $VERSION" +echo "" \ No newline at end of file diff --git a/Makefile b/Makefile index fbc67a6fe6..24a8ae3d05 100644 --- a/Makefile +++ b/Makefile @@ -448,19 +448,7 @@ update-golang: ifndef VERSION $(error VERSION is required. Usage: make update-golang VERSION=1.24.11) endif - @echo "Bumping Go version to $(VERSION)..." - - # Update main go.mod - @echo "Updating main go.mod..." - @sed -i '' -E 's/^go [0-9]+\.[0-9]+.*/go $(VERSION)/' go.mod - - # Update all module go.mod files - @echo "Updating all module go.mod files..." - @find . -name "go.mod" -type f -not -path "./go.mod" -exec sed -i '' -E 's/^go [0-9]+\.[0-9]+\.[0-9]+/go $(VERSION)/g' {} \; - - @echo "" - @echo "✓ Successfully bumped golang version to $(VERSION)" - @echo "" + @./.github/workflows/scripts/update-golang.sh -v $(VERSION) .PHONY: update-otel update-otel:$(MULTIMOD)