Update Golang Version #1213
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Golang Version | |
| permissions: read-all | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" # Runs every day at midnight UTC | |
| workflow_dispatch: | |
| jobs: | |
| update_golang_version: | |
| if: github.repository == 'vitessio/vitess' | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| strategy: | |
| matrix: | |
| branch: [ main, release-24.0, release-23.0 ] | |
| name: Update Golang Version | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Harden the runner (Audit all outbound calls) | |
| uses: step-security/harden-runner@8d3c67de8e2fe68ef647c8db1e6a09f647780f40 # v2.19.0 | |
| with: | |
| egress-policy: audit | |
| - name: Check out code | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| ref: ${{ matrix.branch }} | |
| - name: Set up Go | |
| uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 | |
| with: | |
| go-version-file: go.mod | |
| cache: ${{ (github.base_ref == 'main' || (github.base_ref == '' && github.ref_name == 'main')) && 'true' || 'false' }} | |
| - name: Detect new version and update codebase | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| GOTOOLCHAIN: auto | |
| 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 --main --allow-major-upgrade | |
| else | |
| go run ./go/tools/go-upgrade/go-upgrade.go upgrade | |
| fi | |
| output=$(git status -s) | |
| if [ -z "${output}" ]; then | |
| exit 0 | |
| fi | |
| 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 | |
| # Check if the PR already exists, if it does then do not create new PR. | |
| gh pr list -S 'is:open "[${{ matrix.branch }}] Upgrade the Golang version to go${go_version}"' > out.txt 2>&1 | true | |
| if [ -s out.txt ]; then | |
| rm -f out.txt | |
| exit 0 | |
| fi | |
| rm -f out.txt | |
| echo "create-pr=true" >> $GITHUB_OUTPUT | |
| - name: Create Pull Request | |
| if: steps.detect-and-update.outputs.create-pr == 'true' | |
| uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1 | |
| with: | |
| token: ${{ secrets.CREATE_PR_VITESS_BOT }} | |
| 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 | |
| team-reviewers: Release | |
| 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. | |
| cc @vitessio/release | |
| base: ${{ matrix.branch }} | |
| labels: | | |
| go | |
| Benchmark me | |
| Component: General | |
| Type: CI/Build |