version: 2

before:
  hooks:
    - go mod tidy

builds:
  - id: darwin-amd64
    main: ./
    binary: catalyst
    goos:
      - darwin
    goarch:
      - amd64
    env:
      - CGO_ENABLED=1
      - CC=o64-clang
      - CXX=o64-clang++
    flags:
      - -mod=readonly
    ldflags:
      - -s -w -X main.version={{.Version}}
  - id: linux-arm64
    main: ./
    binary: catalyst
    goos:
      - linux
    goarch:
      - arm64
    env:
      - CGO_ENABLED=1
      - CC=aarch64-linux-gnu-gcc
      - CXX=aarch64-linux-gnu-g++
    flags:
      - -mod=readonly
    ldflags:
      - -s -w -X main.version={{.Version}}
  - id: linux-amd64
    main: ./
    binary: catalyst
    goos:
      - linux
    goarch:
      - amd64
    env:
      - CGO_ENABLED=1
      - CC=x86_64-linux-gnu-gcc
      - CXX=x86_64-linux-gnu-g++
    flags:
      - -mod=readonly
    ldflags:
      - -s -w -X main.version={{.Version}}
  - id: windows-amd64
    main: ./
    binary: catalyst
    goos:
      - windows
    goarch:
      - amd64
    env:
      - CGO_ENABLED=1
      - CC=x86_64-w64-mingw32-gcc
      - CXX=x86_64-w64-mingw32-g++
    flags:
      - -mod=readonly
    ldflags:
      - -s -w -X main.version={{.Version}}
  - id: windows-arm64
    main: ./
    binary: catalyst
    goos:
      - windows
    goarch:
      - arm64
    env:
      - CGO_ENABLED=1
      - CC=/llvm-mingw/bin/aarch64-w64-mingw32-gcc
      - CXX=/llvm-mingw/bin/aarch64-w64-mingw32-g++
    flags:
      - -mod=readonly
    ldflags:
      - -s -w -X main.version={{.Version}}

dockers:
  - ids: [ linux-amd64 ]
    dockerfile: docker/Dockerfile
    image_templates:
      - "ghcr.io/securitybrewery/catalyst:main"
      - "{{if not .Prerelease}}ghcr.io/securitybrewery/catalyst:latest{{end}}"
      - "ghcr.io/securitybrewery/catalyst:{{.Tag}}"
    extra_files:
      - docker/entrypoint.sh

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

changelog:
  sort: asc
