Skip to content

Workflow file for this run

name: Test and Release Go CLI
on: [push]
permissions:
contents: read
# allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read
jobs:
linter:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
- name: Get golangci-lint configuration file
run: wget --output-document=/tmp/golangci.yml https://sc-devtools.s3.eu-west-1.amazonaws.com/golang-ci/golangci.yml
- uses: golangci/golangci-lint-action@v4
with:
# This flag is not working (https://github.com/golangci/golangci-lint-action/issues/531).
# We rather decided to use the suggestion from the FAQ (https://golangci-lint.run/usage/faq/#how-to-integrate-golangci-lint-into-large-project-with-thousands-of-issues) and use `--new` and `--new-from-rev`
# only-new-issues: false
# args: "--config=/tmp/golangci.yml"
args: "--config=/tmp/golangci.yml --new --new-from-rev=HEAD"
tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
- name: Execute the tests
run: go test -race ./...
releases:
needs: [linter, tests]
name: GoReleaser Build on All OS but Windows
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # See: https://goreleaser.com/ci/actions/
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CGO_ENABLED: 0
releases-windows:
needs: tests
name: GoReleaser Build on Windows
if: startsWith(github.ref, 'refs/tags/')
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # See: https://goreleaser.com/ci/actions/
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
check-latest: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --config .goreleaser-windows.yaml --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}