Skip to content
Open
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
132 changes: 132 additions & 0 deletions .github/workflows/go-toolchain-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Go Toolchain Update

on:
workflow_dispatch:
schedule:
- cron: "17 */6 * * *"

permissions:
contents: read

jobs:
update-go-toolchain:
runs-on: ubuntu-24.04
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0

- name: Check Go toolchain baseline
id: versions
run: |
current="$(python3 hack/go-toolchain.py current)"
latest="$(python3 hack/go-toolchain.py latest)"

echo "current=${current}" >> "$GITHUB_OUTPUT"
echo "latest=${latest}" >> "$GITHUB_OUTPUT"

if [ "$current" = "$latest" ]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "Go toolchain already matches latest stable Go ${latest}."
exit 0
fi

echo "changed=true" >> "$GITHUB_OUTPUT"
echo "Go toolchain update needed: ${current} -> ${latest}."

- name: Update Go toolchain files
if: steps.versions.outputs.changed == 'true'
run: python3 hack/go-toolchain.py update --version "${{ steps.versions.outputs.latest }}"

- name: Set up target Go
if: steps.versions.outputs.changed == 'true'
uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
with:
go-version-file: go.mod

- name: Validate Go toolchain update
if: steps.versions.outputs.changed == 'true'
run: |
go mod tidy
python3 hack/go-toolchain.py verify --check-latest --require-latest
git diff --check
git diff --exit-code -- .github/workflows

- name: Create or update pull request
if: steps.versions.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
TARGET_GO_VERSION: ${{ steps.versions.outputs.latest }}
run: |
branch="chore/go-toolchain-${TARGET_GO_VERSION//./}"
title="chore: update Go toolchain to ${TARGET_GO_VERSION}"

git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin "+refs/heads/${branch}:refs/remotes/origin/${branch}" || true
git switch -C "$branch"
git add go.mod go.sum docker/Dockerfile docker/Dockerfile.router docker/Dockerfile.picod

if git diff --cached --quiet; then
echo "No Go toolchain changes remain after update."
exit 0
fi

git commit -s -m "$title"
git push --force-with-lease="refs/heads/${branch}" origin "$branch:$branch"

cat > /tmp/go-toolchain-pr-body.md <<EOF
**What type of PR is this?**

/kind cleanup

**What this PR does / why we need it**:

Updates the project Go toolchain baseline to Go ${TARGET_GO_VERSION}.

This PR keeps the Go baseline aligned across \`go.mod\` and Docker \`golang:*\` builder image tags. GitHub Actions already read the Go version from \`go.mod\` via \`go-version-file: go.mod\`, so regular post-#391 Go baseline updates should not need workflow file changes.

**Which issue(s) this PR fixes**:

NONE

**Special notes for your reviewer**:

- Generated by the scheduled Go Toolchain Update workflow.
- Validation run in the workflow:
- \`python3 hack/go-toolchain.py update --version ${TARGET_GO_VERSION}\`
- \`go mod tidy\`
- \`python3 hack/go-toolchain.py verify --check-latest --require-latest\`
- \`git diff --check\`
- \`git diff --exit-code -- .github/workflows\`
- PRs created with \`GITHUB_TOKEN\` may not recursively trigger every downstream workflow, so normal PR CI should still be checked before merge.

**Does this PR introduce a user-facing change?**:

\`\`\`release-note
NONE
\`\`\`
EOF

existing_pr="$(
gh pr list \
--base main \
--head "$branch" \
--state open \
--json number \
--jq '.[0].number // ""'
)"

if [ -n "$existing_pr" ]; then
gh pr edit "$existing_pr" --title "$title" --body-file /tmp/go-toolchain-pr-body.md
else
gh pr create \
--base main \
--head "$branch" \
--title "$title" \
--body-file /tmp/go-toolchain-pr-body.md
fi
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Multi-stage build for workloadmanager
FROM --platform=$BUILDPLATFORM golang:1.26.4-alpine AS builder
FROM --platform=$BUILDPLATFORM golang:1.26.5-alpine AS builder

# Build arguments for multi-architecture support
ARG TARGETOS=linux
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.picod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build stage
FROM --platform=$BUILDPLATFORM golang:1.26.4 AS builder
FROM --platform=$BUILDPLATFORM golang:1.26.5 AS builder

# Build arguments for multi-architecture support
ARG TARGETOS=linux
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.router
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Multi-stage build for agentcube-router
FROM --platform=$BUILDPLATFORM golang:1.26.4-alpine AS builder
FROM --platform=$BUILDPLATFORM golang:1.26.5-alpine AS builder

# Build arguments for multi-architecture support
ARG TARGETOS=linux
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/volcano-sh/agentcube

go 1.26.4
go 1.26.5

require (
github.com/agiledragon/gomonkey/v2 v2.13.0
Expand Down
Loading