Files
lazyjournal/.github/workflows/go-ver-update.yml
2026-10-28 13:31:14 +03:00

87 lines
2.7 KiB
YAML

name: "[GO] Go version and modules update"
on:
workflow_dispatch:
inputs:
Version:
description: 'Version for Go'
required: true
default: '1.26'
Modules:
description: 'Update dependencies in modules'
default: false
type: boolean
Workflows:
description: 'Update go version in workflows'
default: false
type: boolean
PR:
description: 'Create Pull Request'
default: false
type: boolean
jobs:
updates:
name: Go version and modules update
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout repository (main branch and last commits)
uses: actions/checkout@v7
with:
ref: main
fetch-depth: 1
- name: Install Go ${{ github.event.inputs.Version }}
uses: actions/setup-go@v7
with:
go-version: ${{ github.event.inputs.Version }}
- name: Code verify and check build before updates
run: |
go vet ./...
go build -v -o /dev/null ./...
- name: Update Go version
run: |
go mod edit -go=${{ github.event.inputs.Version }}
# go mod edit -toolchain=go${{ github.event.inputs.Version }}
go mod tidy
- name: Get module list for update
run: go list -m -u all
- name: Update dependencies in modules
if: ${{ github.event.inputs.Modules == 'true' }}
run: |
go get -u ./...
go mod tidy
- name: Code verify and check build after updates
run: |
go vet ./...
go build -v -o /dev/null ./...
- name: Update Go version in workflows
if: ${{ github.event.inputs.Workflows == 'true' }}
run: |
sed -i -E "s/go-version:\s*[0-9.]+/go-version: ${{ github.event.inputs.Version }}/" .github/workflows/*.yml
- name: Create Pull Request for update go version and modules
if: ${{ github.event.inputs.Modules == 'true' && github.event.inputs.PR == 'true' }}
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "update go version and modules"
branch: "ops/go-${{ github.event.inputs.Version }}"
title: "Update the Go version and modules"
body: "Updated Go version to **${{ github.event.inputs.Version }}** as well as the module dependencies in `go.mod` and `go.sum`."
add-paths: |
go.mod
go.sum
.github/workflows/*.yml