# Read the documentation at https://goreleaser.com
# For a full reference of the configuration file.

version: 2

project_name: fabric
before:
  hooks:
    - go mod tidy

builds:
  - id: default
    env:
      - CGO_ENABLED=0
    goos:
      - darwin
      - linux
    main: ./cmd/fabric
    binary: fabric
    ldflags:
      - -s -w
      - -X main.version={{.Version}}
      - -X main.commit={{.ShortCommit}}
      - -X main.date={{.Date}}
      - -X main.builtBy=goreleaser
      - -X main.tag={{.Tag}}

  - id: windows-build
    env:
      - CGO_ENABLED=0
    goos:
      - windows
    main: ./cmd/fabric
    binary: fabric
    ldflags:
      - -s -w
      - -X main.version={{.Version}}
      - -X main.commit={{.ShortCommit}}
      - -X main.date={{.Date}}
      - -X main.builtBy=goreleaser
      - -X main.tag={{.Tag}}

archives:
  - formats: [tar.gz]
    # this name template makes the OS and Arch compatible with the results of `uname`.
    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 }}
    # use zip for windows archives
    format_overrides:
      - goos: windows
        formats: [zip]
