version: 2

release:
  prerelease: auto

changelog:
  use: github-native

gomod:
  proxy: true
  env:
    - GOPROXY=https://proxy.golang.org,direct
    - GOSUMDB=sum.golang.org

builds:
  - id: darwin-builds
    binary: siftool
    goos:
      - darwin
    goarch:
      - amd64
      - arm64
    main: &build-main ./cmd/siftool
    mod_timestamp: &build-timestamp '{{ .CommitTimestamp }}'
    env: &build-env
      - CGO_ENABLED=0
    flags: &build-flags '-trimpath'
    ldflags: &build-ldflags |
      -s
      -w
      -X main.version={{ .Version }}
      -X main.date={{ .CommitDate }}
      -X main.builtBy=goreleaser
      -X main.commit={{ .FullCommit }}

  - id: linux-builds
    binary: siftool
    goos:
      - linux
    goarch:
      - '386'
      - 'amd64'
      - 'arm'
      - 'arm64'
      - 'mips'
      - 'mips64'
      - 'mips64le'
      - 'mipsle'
      - 'ppc64'
      - 'ppc64le'
      - 'riscv64'
      - 's390x'
    goarm:
      - '6'
      - '7'
    main: *build-main
    mod_timestamp: *build-timestamp
    env: *build-env
    flags: *build-flags
    ldflags: *build-ldflags

archives:
  - id: darwin-archives
    builds:
      - darwin-builds

  - id: linux-archives
    builds:
      - linux-builds

sboms:
  - documents:
      - '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}.bom.cdx.json'
    artifacts: binary
    args: ["$artifact", "--file", "$document", "--output", "cyclonedx-json"]
