|
| 1 | +name: Update Golang Version |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "0 0 * * *" # Runs every day at midnight UTC |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + update_golang_version: |
| 10 | + strategy: |
| 11 | + matrix: |
| 12 | + branch: [ main, release-16.0, release-15.0, release-14.0 ] |
| 13 | + name: Update Golang Version |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Set up Go |
| 17 | + uses: actions/setup-go@v2 |
| 18 | + with: |
| 19 | + go-version: 1.20.2 |
| 20 | + |
| 21 | + - name: Check out code |
| 22 | + uses: actions/checkout@v3 |
| 23 | + with: |
| 24 | + ref: ${{ matrix.branch }} |
| 25 | + |
| 26 | + - name: Detect new version and update codebase |
| 27 | + id: detect-and-update |
| 28 | + run: | |
| 29 | + old_go_version=$(go run ./go/tools/go-upgrade/go-upgrade.go get go-version) |
| 30 | + echo "old-go-version=${old_go_version}" >> $GITHUB_OUTPUT |
| 31 | +
|
| 32 | + if [ ${{ matrix.branch }} == "main" ]; then |
| 33 | + go run ./go/tools/go-upgrade/go-upgrade.go upgrade --workflow-update=false --main --allow-major-upgrade |
| 34 | + else |
| 35 | + go run ./go/tools/go-upgrade/go-upgrade.go upgrade --workflow-update=false |
| 36 | + fi |
| 37 | +
|
| 38 | + output=$(git status -s) |
| 39 | + if [ -z "${output}" ]; then |
| 40 | + exit 0 |
| 41 | + fi |
| 42 | + echo "create-pr=true" >> $GITHUB_OUTPUT |
| 43 | +
|
| 44 | + go_version=$(go run ./go/tools/go-upgrade/go-upgrade.go get go-version) |
| 45 | + bootstrap_version=$(go run ./go/tools/go-upgrade/go-upgrade.go get bootstrap-version) |
| 46 | + echo "go-version=${go_version}" >> $GITHUB_OUTPUT |
| 47 | + echo "bootstrap-version=${bootstrap_version}" >> $GITHUB_OUTPUT |
| 48 | +
|
| 49 | + - name: Create Pull Request |
| 50 | + if: steps.detect-and-update.outputs.create-pr == 'true' |
| 51 | + uses: peter-evans/create-pull-request@v4 |
| 52 | + with: |
| 53 | + branch: "upgrade-go-to-${{steps.detect-and-update.outputs.go-version}}-on-${{ matrix.branch }}" |
| 54 | + commit-message: "bump go version to go${{steps.detect-and-update.outputs.go-version}}" |
| 55 | + signoff: true |
| 56 | + delete-branch: true |
| 57 | + title: "[${{ matrix.branch }}] Upgrade the Golang version to `go${{steps.detect-and-update.outputs.go-version}}`" |
| 58 | + body: | |
| 59 | + 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}}`. |
| 60 | +
|
| 61 | + > Do not trust the bot blindly. A thorough code review must be done to ensure all the files have been correctly modified. |
| 62 | +
|
| 63 | + There are a few manual steps remaining: |
| 64 | + - [ ] Make sure you update the Golang version used in the previous and next release branches for the Upgrade/Downgrade tests. |
| 65 | + - [ ] Build and Push the bootstrap images to Docker Hub, the bot cannot handle that. |
| 66 | + - [ ] Update the `./.github/workflows/*.yml` files with the newer Golang version, the bot cannot handle that due to permissions. |
| 67 | + - 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}}` |
| 68 | + base: ${{ matrix.branch }} |
| 69 | + labels: | |
| 70 | + Skip CI |
| 71 | + go |
| 72 | + Benchmark me |
| 73 | + Component: General |
| 74 | + Type: CI/Build |
0 commit comments