From 4d8c08b1db2494c79fc37dd12ecd5b7b3e26bdbc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 00:44:22 +0000 Subject: [PATCH 1/6] Initial plan From 6fc95202299dbc55270cc6f98a5464b7eddd0914 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 00:46:30 +0000 Subject: [PATCH 2/6] Add monthly Go version update workflow Co-authored-by: madhanrm <20309044+madhanrm@users.noreply.github.com> --- .github/workflows/update-go-version.yml | 86 +++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 .github/workflows/update-go-version.yml diff --git a/.github/workflows/update-go-version.yml b/.github/workflows/update-go-version.yml new file mode 100644 index 00000000..d32c0721 --- /dev/null +++ b/.github/workflows/update-go-version.yml @@ -0,0 +1,86 @@ +name: Update Go Version + +on: + schedule: + # Run on the first day of every month at 9:00 AM UTC + - cron: '0 9 1 * *' + workflow_dispatch: # Allow manual triggering + +jobs: + update-go-version: + name: Update Go to Latest Version + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: stable + + - name: Get latest Go version + id: go-version + run: | + # Get the latest stable Go version + LATEST_GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//') + echo "latest=$LATEST_GO_VERSION" >> $GITHUB_OUTPUT + echo "Latest Go version: $LATEST_GO_VERSION" + + - name: Get current Go version from go.mod + id: current-version + run: | + CURRENT_VERSION=$(grep '^go ' go.mod | awk '{print $2}') + echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT + echo "Current Go version in go.mod: $CURRENT_VERSION" + + - name: Update go.mod if needed + id: update + run: | + CURRENT="${{ steps.current-version.outputs.current }}" + LATEST="${{ steps.go-version.outputs.latest }}" + + if [ "$CURRENT" != "$LATEST" ]; then + echo "Updating Go version from $CURRENT to $LATEST" + + # Update the go version in go.mod + sed -i "s/^go .*/go $LATEST/" go.mod + + # Run go mod tidy to update dependencies + go mod tidy + + echo "updated=true" >> $GITHUB_OUTPUT + echo "version=$LATEST" >> $GITHUB_OUTPUT + else + echo "Go version is already up to date ($CURRENT)" + echo "updated=false" >> $GITHUB_OUTPUT + fi + + - name: Create Pull Request + if: steps.update.outputs.updated == 'true' + uses: peter-evans/create-pull-request@v7 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: 'Update Go version to ${{ steps.update.outputs.version }}' + title: 'Update Go version to ${{ steps.update.outputs.version }}' + body: | + This automated PR updates the Go version to the latest stable release: `${{ steps.update.outputs.version }}` + + ## Changes + - Updated `go.mod` to use Go ${{ steps.update.outputs.version }} + - Ran `go mod tidy` to update dependencies + + ## Testing + Please review the changes and ensure all tests pass before merging. + + --- + This PR was automatically created by the [Update Go Version workflow](.github/workflows/update-go-version.yml). + branch: update-go-version-${{ steps.update.outputs.version }} + delete-branch: true + labels: | + dependencies + automated From b38bf9e7a6959407f2996b15a5f523c841768d7e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 00:47:48 +0000 Subject: [PATCH 3/6] Improve version comparison logic in Go update workflow Co-authored-by: madhanrm <20309044+madhanrm@users.noreply.github.com> --- .github/workflows/update-go-version.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/update-go-version.yml b/.github/workflows/update-go-version.yml index d32c0721..e32a7acc 100644 --- a/.github/workflows/update-go-version.yml +++ b/.github/workflows/update-go-version.yml @@ -26,8 +26,9 @@ jobs: - name: Get latest Go version id: go-version run: | - # Get the latest stable Go version - LATEST_GO_VERSION=$(go version | awk '{print $3}' | sed 's/go//') + # Get the latest stable Go version from the installed Go + # go version outputs like "go version go1.21.5 linux/amd64" + LATEST_GO_VERSION=$(go version | awk '{print $3}' | sed 's/^go//') echo "latest=$LATEST_GO_VERSION" >> $GITHUB_OUTPUT echo "Latest Go version: $LATEST_GO_VERSION" @@ -44,7 +45,16 @@ jobs: CURRENT="${{ steps.current-version.outputs.current }}" LATEST="${{ steps.go-version.outputs.latest }}" - if [ "$CURRENT" != "$LATEST" ]; then + # Normalize versions for comparison (remove any extra components) + # Convert versions like "1.21.5" to comparable format + normalize_version() { + echo "$1" | awk -F. '{printf "%03d%03d%03d", $1, $2, $3}' + } + + CURRENT_NORMALIZED=$(normalize_version "$CURRENT") + LATEST_NORMALIZED=$(normalize_version "$LATEST") + + if [ "$CURRENT_NORMALIZED" != "$LATEST_NORMALIZED" ]; then echo "Updating Go version from $CURRENT to $LATEST" # Update the go version in go.mod From c443cb3a377b7db0edad68968df0939dd03eeace Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 00:48:40 +0000 Subject: [PATCH 4/6] Fix version normalization to handle all Go version formats Co-authored-by: madhanrm <20309044+madhanrm@users.noreply.github.com> --- .github/workflows/update-go-version.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update-go-version.yml b/.github/workflows/update-go-version.yml index e32a7acc..fab09663 100644 --- a/.github/workflows/update-go-version.yml +++ b/.github/workflows/update-go-version.yml @@ -35,7 +35,7 @@ jobs: - name: Get current Go version from go.mod id: current-version run: | - CURRENT_VERSION=$(grep '^go ' go.mod | awk '{print $2}') + CURRENT_VERSION=$(grep '^go [0-9]' go.mod | awk '{print $2}') echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT echo "Current Go version in go.mod: $CURRENT_VERSION" @@ -45,10 +45,17 @@ jobs: CURRENT="${{ steps.current-version.outputs.current }}" LATEST="${{ steps.go-version.outputs.latest }}" - # Normalize versions for comparison (remove any extra components) - # Convert versions like "1.21.5" to comparable format + # Normalize versions for comparison + # Convert versions like "1.21.5" or "1.21" to comparable format + # Handles versions with 2 or 3 components (major.minor or major.minor.patch) normalize_version() { - echo "$1" | awk -F. '{printf "%03d%03d%03d", $1, $2, $3}' + local ver="$1" + local major=$(echo "$ver" | cut -d. -f1) + local minor=$(echo "$ver" | cut -d. -f2) + local patch=$(echo "$ver" | cut -d. -f3) + # Default patch to 0 if not present + patch=${patch:-0} + printf "%03d%03d%03d" "$major" "$minor" "$patch" } CURRENT_NORMALIZED=$(normalize_version "$CURRENT") From e3bc57a2e61d596c5bda8a683a9c23a9519cd107 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 00:49:37 +0000 Subject: [PATCH 5/6] Add validation and improve version handling robustness Co-authored-by: madhanrm <20309044+madhanrm@users.noreply.github.com> --- .github/workflows/update-go-version.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-go-version.yml b/.github/workflows/update-go-version.yml index fab09663..3fa927fa 100644 --- a/.github/workflows/update-go-version.yml +++ b/.github/workflows/update-go-version.yml @@ -35,7 +35,7 @@ jobs: - name: Get current Go version from go.mod id: current-version run: | - CURRENT_VERSION=$(grep '^go [0-9]' go.mod | awk '{print $2}') + CURRENT_VERSION=$(grep '^go [0-9][0-9.]*' go.mod | awk '{print $2}') echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT echo "Current Go version in go.mod: $CURRENT_VERSION" @@ -53,9 +53,18 @@ jobs: local major=$(echo "$ver" | cut -d. -f1) local minor=$(echo "$ver" | cut -d. -f2) local patch=$(echo "$ver" | cut -d. -f3) + + # Validate that we have at least major and minor versions + if [ -z "$major" ] || [ -z "$minor" ]; then + echo "Invalid version format: $ver" >&2 + return 1 + fi + # Default patch to 0 if not present patch=${patch:-0} - printf "%03d%03d%03d" "$major" "$minor" "$patch" + + # Use larger padding to handle future versions + printf "%05d%05d%05d" "$major" "$minor" "$patch" } CURRENT_NORMALIZED=$(normalize_version "$CURRENT") From 5a7d1e172a97fb5348ab957463e4322c686c76d7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 27 Jan 2026 00:50:33 +0000 Subject: [PATCH 6/6] Improve version parsing robustness with proper error handling Co-authored-by: madhanrm <20309044+madhanrm@users.noreply.github.com> --- .github/workflows/update-go-version.yml | 27 +++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/update-go-version.yml b/.github/workflows/update-go-version.yml index 3fa927fa..87d267c6 100644 --- a/.github/workflows/update-go-version.yml +++ b/.github/workflows/update-go-version.yml @@ -50,25 +50,40 @@ jobs: # Handles versions with 2 or 3 components (major.minor or major.minor.patch) normalize_version() { local ver="$1" - local major=$(echo "$ver" | cut -d. -f1) - local minor=$(echo "$ver" | cut -d. -f2) - local patch=$(echo "$ver" | cut -d. -f3) + + # Split version into components using bash parameter expansion + IFS='.' read -ra PARTS <<< "$ver" + + local major="${PARTS[0]}" + local minor="${PARTS[1]}" + local patch="${PARTS[2]:-0}" # Validate that we have at least major and minor versions if [ -z "$major" ] || [ -z "$minor" ]; then - echo "Invalid version format: $ver" >&2 + echo "Invalid version format: $ver (missing major or minor)" >&2 return 1 fi - # Default patch to 0 if not present - patch=${patch:-0} + # Validate that all components are numeric + if ! [[ "$major" =~ ^[0-9]+$ ]] || ! [[ "$minor" =~ ^[0-9]+$ ]] || ! [[ "$patch" =~ ^[0-9]+$ ]]; then + echo "Invalid version format: $ver (non-numeric components)" >&2 + return 1 + fi # Use larger padding to handle future versions printf "%05d%05d%05d" "$major" "$minor" "$patch" } CURRENT_NORMALIZED=$(normalize_version "$CURRENT") + CURRENT_EXIT=$? LATEST_NORMALIZED=$(normalize_version "$LATEST") + LATEST_EXIT=$? + + # Check if normalization succeeded + if [ $CURRENT_EXIT -ne 0 ] || [ $LATEST_EXIT -ne 0 ]; then + echo "Error: Failed to normalize versions" + exit 1 + fi if [ "$CURRENT_NORMALIZED" != "$LATEST_NORMALIZED" ]; then echo "Updating Go version from $CURRENT to $LATEST"