From 14f72fb24bc5b436898e18b30568dd139f1022e6 Mon Sep 17 00:00:00 2001 From: eferreyra Date: Thu, 12 Mar 2026 14:00:10 -0400 Subject: [PATCH 1/6] chore: autobump golang when updating otel --- .github/workflows/update-otel.yaml | 4 +++- Makefile | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update-otel.yaml b/.github/workflows/update-otel.yaml index df08fda8cb..4bec2cb0d7 100644 --- a/.github/workflows/update-otel.yaml +++ b/.github/workflows/update-otel.yaml @@ -46,6 +46,7 @@ jobs: exec > >(tee log.out) 2>&1 LAST_COMMIT="$(git -C ./opentelemetry-collector/ rev-parse HEAD)" LAST_CONTRIB_COMMIT="$(git -C ./opentelemetry-collector-contrib/ rev-parse HEAD)" + GO_VERSION="$(grep '^go ' ./opentelemetry-collector/service/go.mod | awk '{print $2}')" cd nrdot-collector-components git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" @@ -54,6 +55,7 @@ jobs: make gennrdotcol echo "LAST_COMMIT=$LAST_COMMIT" >> "$GITHUB_ENV" echo "LAST_CONTRIB_COMMIT=$LAST_CONTRIB_COMMIT" >> "$GITHUB_ENV" + echo "GO_VERSION=$GO_VERSION" >> "$GITHUB_ENV" echo "BRANCH_NAME=$branch" >> "$GITHUB_ENV" - name: Gets packages from links with retries uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2 @@ -64,7 +66,7 @@ jobs: retry_on: error command: | cd nrdot-collector-components - make update-otel OTEL_STABLE_VERSION=${{ env.LAST_COMMIT }} OTEL_VERSION=${{ env.LAST_COMMIT }} CONTRIB_VERSION=${{ env.LAST_CONTRIB_COMMIT }} + make update-otel OTEL_STABLE_VERSION=${{ env.LAST_COMMIT }} OTEL_VERSION=${{ env.LAST_COMMIT }} CONTRIB_VERSION=${{ env.LAST_CONTRIB_COMMIT }} GO_VERSION=${{ env.GO_VERSION }} - name: Push and create PR run: | cd nrdot-collector-components diff --git a/Makefile b/Makefile index 9bef3e3927..fbc67a6fe6 100644 --- a/Makefile +++ b/Makefile @@ -443,11 +443,36 @@ define updatehelper done endef +.PHONY: update-golang +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 "" + .PHONY: update-otel update-otel:$(MULTIMOD) # Make sure cmd/nrdotcol/go.mod and cmd/oteltestbedcol/go.mod are present $(MAKE) gennrdotcol $(MAKE) genoteltestbedcol + # Update Go version if provided +ifdef GO_VERSION + @echo "Updating Go version to $(GO_VERSION)..." + $(MAKE) update-golang VERSION=$(GO_VERSION) + git add . && git commit -s -m "[chore] update golang to $(GO_VERSION)" --allow-empty || true +endif $(MULTIMOD) sync -s=true -o ../opentelemetry-collector -m stable --commit-hash "$(OTEL_STABLE_VERSION)" git add . && git commit -s -m "[chore] multimod update stable modules" || true $(MULTIMOD) sync -s=true -o ../opentelemetry-collector -m beta --commit-hash "$(OTEL_VERSION)" From 12b79e4bc40087508f101defc63915573102b0e4 Mon Sep 17 00:00:00 2001 From: eferreyra Date: Thu, 12 Mar 2026 14:32:35 -0400 Subject: [PATCH 2/6] trigger checks From 373ae6aab44d11d5e2b83f40abd453dd7c6917b5 Mon Sep 17 00:00:00 2001 From: eferreyra Date: Fri, 13 Mar 2026 11:42:59 -0400 Subject: [PATCH 3/6] use sed syntax that is portable to both mac and linux (which github actions uses) --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index fbc67a6fe6..f4513174ac 100644 --- a/Makefile +++ b/Makefile @@ -452,11 +452,11 @@ endif # Update main go.mod @echo "Updating main go.mod..." - @sed -i '' -E 's/^go [0-9]+\.[0-9]+.*/go $(VERSION)/' go.mod + @sed -i.bak -E 's/^go [0-9]+\.[0-9]+.*/go $(VERSION)/' go.mod && rm go.mod.bak # 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' {} \; + @find . -name "go.mod" -type f -not -path "./go.mod" -exec sed -i.bak -E 's/^go [0-9]+\.[0-9]+\.[0-9]+/go $(VERSION)/g' {} \; && find . -name "go.mod.bak" -type f -delete @echo "" @echo "✓ Successfully bumped golang version to $(VERSION)" From e8312ad26dbe3abcfe83a866aacfe2bc6157d2c8 Mon Sep 17 00:00:00 2001 From: eferreyra Date: Fri, 13 Mar 2026 15:36:15 -0400 Subject: [PATCH 4/6] move logic out into script and add a os check --- .github/workflows/scripts/update-golang.sh | 45 ++++++++++++++++++++++ Makefile | 14 +------ 2 files changed, 46 insertions(+), 13 deletions(-) create mode 100755 .github/workflows/scripts/update-golang.sh diff --git a/.github/workflows/scripts/update-golang.sh b/.github/workflows/scripts/update-golang.sh new file mode 100755 index 0000000000..a04f2df15c --- /dev/null +++ b/.github/workflows/scripts/update-golang.sh @@ -0,0 +1,45 @@ +#!/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 + +# Update main go.mod +echo "Updating main go.mod..." +sed_inplace -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 bash -c 'sed_inplace() { if [[ "$OSTYPE" == "darwin"* ]]; then sed -i "" "$@"; else sed -i "$@"; fi; }; sed_inplace -E "s/^go [0-9]+\.[0-9]+\.[0-9]+/go '"$VERSION"'/g" "$1"' bash {} \; + +echo "" +echo "✓ Successfully bumped golang version to $VERSION" +echo "" \ No newline at end of file diff --git a/Makefile b/Makefile index f4513174ac..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.bak -E 's/^go [0-9]+\.[0-9]+.*/go $(VERSION)/' go.mod && rm go.mod.bak - - # 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.bak -E 's/^go [0-9]+\.[0-9]+\.[0-9]+/go $(VERSION)/g' {} \; && find . -name "go.mod.bak" -type f -delete - - @echo "" - @echo "✓ Successfully bumped golang version to $(VERSION)" - @echo "" + @./.github/workflows/scripts/update-golang.sh -v $(VERSION) .PHONY: update-otel update-otel:$(MULTIMOD) From e0b4dd706123c6422f8ecdd870c7027435eeecb2 Mon Sep 17 00:00:00 2001 From: Emilia Ferreyra <110185663+emiliaFer@users.noreply.github.com> Date: Mon, 16 Mar 2026 09:46:08 -0700 Subject: [PATCH 5/6] Apply suggestions from code review Co-authored-by: kb-newrelic <121687305+kb-newrelic@users.noreply.github.com> --- .github/workflows/scripts/update-golang.sh | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/.github/workflows/scripts/update-golang.sh b/.github/workflows/scripts/update-golang.sh index a04f2df15c..c5f5ec37ab 100755 --- a/.github/workflows/scripts/update-golang.sh +++ b/.github/workflows/scripts/update-golang.sh @@ -20,25 +20,9 @@ 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 - -# Update main go.mod -echo "Updating main go.mod..." -sed_inplace -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 bash -c 'sed_inplace() { if [[ "$OSTYPE" == "darwin"* ]]; then sed -i "" "$@"; else sed -i "$@"; fi; }; sed_inplace -E "s/^go [0-9]+\.[0-9]+\.[0-9]+/go '"$VERSION"'/g" "$1"' bash {} \; +# Update all go.mod files +echo "Updating all go.mod files..." +find . -name "go.mod" -type f -exec bash -c 'sed_inplace() { if [[ "$OSTYPE" == "darwin"* ]]; then sed -i "" "$@"; else sed -i "$@"; fi; }; sed_inplace -E "s/^go [0-9]+\.[0-9]+.*/go '"$VERSION"'/g" "$1"' bash {} \; echo "" echo "✓ Successfully bumped golang version to $VERSION" From c04edd41770a5d46b86a6c8ce0668a28707382a8 Mon Sep 17 00:00:00 2001 From: eferreyra Date: Mon, 16 Mar 2026 13:02:23 -0400 Subject: [PATCH 6/6] move sed_inplace function out of find statement for clarity --- .github/workflows/scripts/update-golang.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/scripts/update-golang.sh b/.github/workflows/scripts/update-golang.sh index c5f5ec37ab..7bb794db2b 100755 --- a/.github/workflows/scripts/update-golang.sh +++ b/.github/workflows/scripts/update-golang.sh @@ -20,9 +20,27 @@ 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..." -find . -name "go.mod" -type f -exec bash -c 'sed_inplace() { if [[ "$OSTYPE" == "darwin"* ]]; then sed -i "" "$@"; else sed -i "$@"; fi; }; sed_inplace -E "s/^go [0-9]+\.[0-9]+.*/go '"$VERSION"'/g" "$1"' bash {} \; +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"