gha: use go version from go.mod, bump to 1.21 #73
Workflow file for this run
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
name: ci | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
permissions: | |
# these perms needed for goreleaser to publish releases and docker images (https://goreleaser.com/ci/actions/#token-permissions): | |
contents: write | |
packages: write | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- uses: golangci/golangci-lint-action@v3 | |
# installed here to run lint on the .goreleaser.yml file: | |
- name: Install GoReleaser | |
uses: goreleaser/goreleaser-action@v4 | |
with: | |
install-only: true | |
- run: make lint | |
- run: make test | |
release-test: | |
# only run goreleaser snapshot on non-main branch | |
if: github.ref != 'refs/heads/main' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- uses: golangci/golangci-lint-action@v3 | |
- name: Install GoReleaser | |
uses: goreleaser/goreleaser-action@v4 | |
with: | |
install-only: true | |
- run: make snapshot | |
release: | |
if: github.ref == 'refs/heads/main' | |
needs: [test] | |
runs-on: ubuntu-latest | |
# only create a release on main builds: | |
steps: | |
- name: checkout code with full history (unshallow) | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
fetch-tags: true | |
- uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- name: install autotag binary | |
run: | | |
curl -sL https://git.io/autotag-install | sudo sh -s -- -b /usr/local/bin | |
- name: Install GoReleaser | |
uses: goreleaser/goreleaser-action@v4 | |
with: | |
install-only: true | |
- name: login to ghcr.io | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: do release | |
run: make release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |