version: 2

before:
  hooks:
    - go mod tidy

builds:
  - env:
      - CGO_ENABLED=0
    goos:
      - linux
      - windows
      - darwin
    goarch:
      - amd64
      - arm64
    ignore:
      - goos: windows
        goarch: arm64
    ldflags:
      - -s -w
      - -X github.com/safedep/pmg/internal/version.Version={{.Version}}
      - -X github.com/safedep/pmg/internal/version.Commit={{.Commit}}

archives:
  - formats: [tar.gz]
    name_template: >-
      {{ .ProjectName }}_
      {{- title .Os }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else if eq .Arch "386" }}i386
      {{- else }}{{ .Arch }}{{ end }}
      {{- if .Arm }}v{{ .Arm }}{{ end }}
    format_overrides:
      - goos: windows
        formats: [zip]

changelog:
  sort: asc
  filters:
    exclude:
      - "^docs:"
      - "^test:"

checksum:
  name_template: 'checksums.txt'
  algorithm: sha256

universal_binaries:
  - replace: true

homebrew_casks:
  - name: pmg
    directory: Casks
    homepage: https://github.com/safedep/pmg
    description: "PMG protects developers from malicious packages"
    license: "Apache-2.0"
    binaries:
      - pmg
    url:
      verified: github.com/safedep/pmg
    hooks:
      post:
        install: |
          if OS.mac?
            system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/pmg"]
          end
    repository:
      owner: safedep
      name: homebrew-tap
      branch: main


