A Github Action that checks for Go upgrades and modifies the go.mod
file accordingly.
- uses: StefMa/Upgrade-Go-Action@{latestRelease or main}
with:
base-branch: 'master' # Defaults to 'main' if absent
gh-token: {{ secrets.CUSTOM_TOKEN }} # Optional to provide a custom token
It is like Dependabot or the Gradle Wrapper Upgrade Gradle Plugin. You shouldn't really care about the Go version as long as you don't build a Go library. You can always be on the bleeding edge 🙂
So, why not?
A fully working example can be seen below. It make sense to run this Action periodically to check for new Go versions.
name: Upgrade Go
on:
workflow_dispatch:
schedule:
- cron: "0 8 * * MON"
jobs:
upgrade-go:
runs-on: ubuntu-latest
permissions: # Only required if using default `secrets.GITHUB_TOKEN`
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: StefMa/Upgrade-Go-Action@main
with:
base-branch: 'master'
gh-token: ${{ secrets.CUSTOM_TOKEN }}
Full a full-reference, checkout the action.yml
file.
base-branch
The (base) branch where the PR will be created against at. Default is main.
gh-token
The gh-token that is used to create the pull request. Defaults to secrets.GITHUB_TOKEN
.
Please note that actions on the created PR won't run with that token. So a custom token might be desired.
Important
Using the default secrets.GITHUB_TOKEN
requires enabling
"GitHub Actions are allowed to create PRs" in the repository settings.
Settings -> Actions -> General -> (Scroll down) Allow GitHub Actions to create and approve pull requests
- Navigate to the Actions tab in your repository.
- Select the "Create Release" workflow.
- Click on "Run workflow" and enter the new version number (e.g.,
1.2.3
).
The new version tag will be created as well as the major tag will be created or updated. Also a draft GitHub release will be generated. You can view the releases on the Releases page.