# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
  hooks:
    # You may remove this if you don't use go modules.
    - go mod tidy
    # you may remove this if you don't need go generate
    # - go generate ./...

builds:
  - id: "win-amd64-dll-release"
    env:
      - CGO_ENABLED=1
      - CC=x86_64-w64-mingw32-gcc
      - CXX=x86_64-w64-mingw32-g++
    goos:
      - windows
    goarch:
      - amd64
    ldflags:
      - -w -trimpath
    gobinary: "scripts/garble.sh"
    buildmode: c-shared
    tags:
      - release
      - dll

  - id: "win-dll-loader"
    env:
      - CGO_ENABLED=1
      - CC=x86_64-w64-mingw32-gcc
      - CXX=x86_64-w64-mingw32-g++
    main: ./cmd/win-dll-runner/main.go
    ldflags:
      - -w
    gobinary: "scripts/garble.sh"
    goos:
      - windows
    goarch:
      - amd64
    tags:
      - release


  - id: "win-release"
    env:
      - CGO_ENABLED=1
      - CC=x86_64-w64-mingw32-gcc
      - CXX=x86_64-w64-mingw32-g++
    goos:
      - windows
    goarch:
      - amd64
    ldflags:
      - "-H=windowsgui"
    gobinary: "scripts/garble.sh"
    tags:
      - release
      - windows

upx:
  - # Whether to enable it or not.
    #
    # Templates: allowed.
    enabled: false

    # Filter by build ID.
    #ids: [build1, build2]

    # Filter by GOOS.
    goos: [windows]

    # Filter by GOARCH.
    goarch: [amd64]

    # Filter by GOARM.
    # goarm: [8]

    # Filter by GOAMD64.
    # goamd64: [v1]

    # Compress argument.
    # Valid options are from '1' (faster) to '9' (better), and 'best'.
    compress: best

    # Whether to try LZMA (slower).
    lzma: true

    # Whether to try all methods and filters (slow).
    brute: true

archives:
  - format: 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
        format: zip

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