Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-14.0] Auto upgrade the Golang version (#12585) #12707

Merged
merged 4 commits into from
Mar 24, 2023
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
74 changes: 74 additions & 0 deletions .github/workflows/update_golang_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Update Golang Version

on:
schedule:
- cron: "0 0 * * *" # Runs every day at midnight UTC
workflow_dispatch:

jobs:
update_golang_version:
strategy:
matrix:
branch: [ main, release-16.0, release-15.0, release-14.0 ]
name: Update Golang Version
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.20.2

- name: Check out code
uses: actions/checkout@v3
with:
ref: ${{ matrix.branch }}

- name: Detect new version and update codebase
id: detect-and-update
run: |
old_go_version=$(go run ./go/tools/go-upgrade/go-upgrade.go get go-version)
echo "old-go-version=${old_go_version}" >> $GITHUB_OUTPUT

if [ ${{ matrix.branch }} == "main" ]; then
go run ./go/tools/go-upgrade/go-upgrade.go upgrade --workflow-update=false --main --allow-major-upgrade
else
go run ./go/tools/go-upgrade/go-upgrade.go upgrade --workflow-update=false
fi

output=$(git status -s)
if [ -z "${output}" ]; then
exit 0
fi
echo "create-pr=true" >> $GITHUB_OUTPUT

go_version=$(go run ./go/tools/go-upgrade/go-upgrade.go get go-version)
bootstrap_version=$(go run ./go/tools/go-upgrade/go-upgrade.go get bootstrap-version)
echo "go-version=${go_version}" >> $GITHUB_OUTPUT
echo "bootstrap-version=${bootstrap_version}" >> $GITHUB_OUTPUT

- name: Create Pull Request
if: steps.detect-and-update.outputs.create-pr == 'true'
uses: peter-evans/create-pull-request@v4
with:
branch: "upgrade-go-to-${{steps.detect-and-update.outputs.go-version}}-on-${{ matrix.branch }}"
commit-message: "bump go version to go${{steps.detect-and-update.outputs.go-version}}"
signoff: true
delete-branch: true
title: "[${{ matrix.branch }}] Upgrade the Golang version to `go${{steps.detect-and-update.outputs.go-version}}`"
body: |
This Pull Request bumps the Golang version to `go${{steps.detect-and-update.outputs.go-version}}` and the bootstrap version to `${{steps.detect-and-update.outputs.bootstrap-version}}`.

> Do not trust the bot blindly. A thorough code review must be done to ensure all the files have been correctly modified.

There are a few manual steps remaining:
- [ ] Make sure you update the Golang version used in the previous and next release branches for the Upgrade/Downgrade tests.
- [ ] Build and Push the bootstrap images to Docker Hub, the bot cannot handle that.
- [ ] Update the `./.github/workflows/*.yml` files with the newer Golang version, the bot cannot handle that due to permissions.
- To accomplish this, run the following: `go run ./go/tools/go-upgrade/go-upgrade.go upgrade workflows --go-to=${{steps.detect-and-update.outputs.go-version}}`
base: ${{ matrix.branch }}
labels: |
Skip CI
go
Benchmark me
Component: General
Type: CI/Build
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ require (
github.com/samuel/go-zookeeper v0.0.0-20200724154423-2164a8ac840e
github.com/sjmudd/stopwatch v0.0.0-20170613150411-f380bf8a9be1
github.com/soheilhy/cmux v0.1.4
github.com/spf13/cobra v1.1.1
github.com/spf13/cobra v1.6.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.8.1
github.com/spyzhov/ajson v0.4.2
Expand Down Expand Up @@ -145,9 +145,10 @@ require (
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
github.com/hashicorp/go-hclog v0.12.0 // indirect
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
github.com/hashicorp/go-version v1.6.0
github.com/hashicorp/golang-lru v0.5.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jessevdk/go-flags v1.4.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
Expand Down Expand Up @@ -187,7 +188,7 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.20.6 // indirect
k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac // indirect
k8s.io/klog v1.0.0 // indirect
Expand Down
Loading