-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable go version upgrade workflow (#4929)
* enable go version upgrade workflow Signed-off-by: deepthi <deepthi@planetscale.com> * fix code owners Signed-off-by: deepthi <deepthi@planetscale.com> * fix code owner errors Signed-off-by: deepthi <deepthi@planetscale.com> * configure private repo access Signed-off-by: deepthi <deepthi@planetscale.com> * revert changes to upstream file and create private-only version Signed-off-by: deepthi <deepthi@planetscale.com> * fix code owner errors Signed-off-by: deepthi <deepthi@planetscale.com> --------- Signed-off-by: deepthi <deepthi@planetscale.com>
- Loading branch information
Showing
4 changed files
with
120 additions
and
29 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
name: Update Golang Version | ||
|
||
on: | ||
schedule: | ||
- cron: "0 0 * * *" # Runs every day at midnight UTC | ||
workflow_dispatch: | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
update_golang_version: | ||
if: github.repository == 'planetscale/vitess-private' | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
strategy: | ||
matrix: | ||
branch: [ upstream, latest-19.0, latest-18.0, latest-17.0, latest-16.0 ] | ||
name: Update Golang Version | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Configure git private repo access | ||
env: | ||
GITHUB_TOKEN: ${{"{{"}} secrets.PLANETSCALE_ACTIONS_BOT_TOKEN {{"}}"}} | ||
run: | | ||
git config --global --add url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/" | ||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22.2 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ matrix.branch }} | ||
|
||
- name: Detect new version and update codebase | ||
env: | ||
GH_TOKEN: ${{ secrets.PLANETSCALE_ACTIONS_BOT_TOKEN }} | ||
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 | ||
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@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. | ||
- [ ] 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 | ||
Component: General | ||
Type: CI/Build |
Empty file.
This file contains 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