name: "main"

on:
  push:
    branches: ["master"]
  pull_request:
    types: ["opened", "synchronize", "reopened"]

jobs:
  test:
    name: "test"
    runs-on: "ubuntu-latest"
    permissions:
      contents: "read"
      pull-requests: "read"
      packages: "write"
      id-token: "write"
    steps:
      - uses: "actions/checkout@v4"
      - run: |
          sudo apt-get install pandoc
      - uses: "sigstore/cosign-installer@v3"
      - uses: "anchore/sbom-action/download-syft@v0"
      - uses: "docker/setup-qemu-action@v3"
      - uses: "docker/setup-buildx-action@v3"
      - uses: "actions/setup-go@v5"
        with:
          go-version: "1.26"
      - uses: "actions/cache@v4"
        with:
          path: |
            ~/.cache/go-build
            ~/go/pkg/mod
          key: ${{ runner.os }}-go-1.26-${{ hashFiles('**/go.sum') }}
          restore-keys: |
            ${{ runner.os }}-go-1.26-
      - run: |
          go mod download
      - run: |
          go mod verify
      - run: |
          make vet
      - run: |
          make test
      - run: |
          make test-fuzz
      - uses: "goreleaser/goreleaser-action@v6"
        with:
          distribution: "goreleaser"
          version: "~> v2"
          args: "release --clean --snapshot"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
