on:
  push:
    branches: ["master"]
  pull_request:
name: tests
jobs:
  test:
    strategy:
      matrix:
        # Test oldest and newest supported version
        go-version: [1.18.x, 1.21.x, 1.22.x, 1.23.x]
        platform: [ubuntu-latest, macos-latest, windows-latest]
    runs-on: ${{ matrix.platform }}
    steps:
    - name: Install Go
      uses: actions/setup-go@v3
      with:
        go-version: ${{ matrix.go-version }}
    - name: Checkout code
      uses: actions/checkout@v4
    - name: Test
      run: go test ./...
    - name: Vet
      run: go vet ./...
  linting:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
      - name: Set up Go
        uses: actions/setup-go@v3
        with:
          go-version: 1.22.x
      - name: Run golangci-lint
        uses: golangci/golangci-lint-action@v3
        with:
          only-new-issues: true

  goreleaser:
    needs:
      - test
      - linting
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Unshallow
        run: git fetch --prune --unshallow
      - name: Set up Go
        uses: actions/setup-go@v3
        with:
          go-version: 1.22.x
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v1
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v1
      - name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v3
        with:
          version: latest
          args: release --rm-dist --skip-publish
