Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/scripts/update-golang.sh
Original file line number Diff line number Diff line change
@@ -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 <version>"
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 ""
14 changes: 1 addition & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading