# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
version: 2
project_name: jfa-go
release:
    github:
        owner: hrfee
        name: jfa-go
    name_template: "v{{.Version}}"
before:
  hooks:
    - npm i
    - make precompile
builds:
    - id: notray
      dir: ./
      flags:
        - -tags={{ .Env.JFA_GO_TAG }}
      ldflags:
        - -X main.version={{.Env.JFA_GO_VERSION}} -X main.commit={{.ShortCommit}} -X main.updater={{.Env.JFA_GO_UPDATER}} {{.Env.JFA_GO_STRIP}} -X main.cssVersion={{.Env.JFA_GO_CSS_VERSION}} -X main.buildTimeUnix={{.Env.JFA_GO_BUILD_TIME}} -X main.builtBy="{{.Env.JFA_GO_BUILT_BY}}"
      goos:
        - linux
        - darwin
        - windows
      goarch:
        - arm
        - arm64
        - amd64
    - id: notray-e2ee
      dir: ./
      env:
        - CGO_ENABLED=1
        - CC={{ if eq .Arch "amd64" }}x86_64{{ else if eq .Arch "arm64" }}aarch64{{ else }}{{ .Arch }}{{ end }}-linux-gnu{{ if eq .Arch "arm" }}eabihf{{ end }}-gcc
        - CXX={{ if eq .Arch "amd64" }}x86_64{{ else if eq .Arch "arm64" }}aarch64{{ else }}{{ .Arch }}{{ end }}-linux-gnu{{ if eq .Arch "arm" }}eabihf{{ end }}-gcc
        - PKG_CONFIG_PATH=/usr/lib/{{ if eq .Arch "amd64" }}x86_64{{ else if eq .Arch "arm64" }}aarch64{{ else }}{{ .Arch }}{{ end }}-linux-gnu{{ if eq .Arch "arm" }}eabihf{{ end }}/pkgconfig:$PKG_CONFIG_PATH
        - GOARM={{ if eq .Arch "arm" }}7{{ end }}
      flags:
        - -tags=e2ee,{{ .Env.JFA_GO_TAG }}
      ldflags:
        - -X main.version={{.Env.JFA_GO_VERSION}} -X main.commit={{.ShortCommit}} -X main.updater={{.Env.JFA_GO_UPDATER}} {{.Env.JFA_GO_STRIP}} -X main.cssVersion={{.Env.JFA_GO_CSS_VERSION}} -X main.buildTimeUnix={{.Env.JFA_GO_BUILD_TIME}} -X main.builtBy="{{.Env.JFA_GO_BUILT_BY}}"
      goos:
        - linux
      goarch:
        - arm
        - arm64
        - amd64
    - id: windows-tray
      dir: ./
      env:
        - CGO_ENABLED=1
        - CC=x86_64-w64-mingw32-gcc
        - CXX=x86_64-w64-mingw32-g++
      flags:
        - -tags=tray,{{ .Env.JFA_GO_TAG }}
      ldflags:
        - -X main.version={{.Env.JFA_GO_VERSION}} -X main.commit={{.ShortCommit}} -X main.updater={{.Env.JFA_GO_UPDATER}} {{.Env.JFA_GO_STRIP}} -X main.cssVersion={{.Env.JFA_GO_CSS_VERSION}} -X main.buildTimeUnix={{.Env.JFA_GO_BUILD_TIME}} -X main.builtBy="{{.Env.JFA_GO_BUILT_BY}}" -H=windowsgui
      goos:
        - windows
      goarch:
        - amd64
    - id: linux-tray
      dir: ./
      env:
        - CGO_ENABLED=1
        - CC=x86_64-linux-gnu-gcc
        - CXX=x86_64-linux-gnu-gcc
        - PKG_CONFIG_PATH=/usr/lib/{{ if eq .Arch "amd64" }}x86_64{{ else if eq .Arch "arm64" }}aarch64{{ else }}{{ .Arch }}{{ end }}-linux-gnu{{ if eq .Arch "arm" }}eabihf{{ end }}/pkgconfig:$PKG_CONFIG_PATH
      flags:
        - -tags=tray,e2ee,{{ .Env.JFA_GO_TAG }}
      ldflags:
        - -X main.version={{.Env.JFA_GO_VERSION}} -X main.commit={{.ShortCommit}} -X main.updater={{.Env.JFA_GO_UPDATER}} {{.Env.JFA_GO_STRIP}} -X main.cssVersion={{.Env.JFA_GO_CSS_VERSION}} -X main.buildTimeUnix={{.Env.JFA_GO_BUILD_TIME}} -X main.builtBy="{{.Env.JFA_GO_BUILT_BY}}"
      goos:
        - linux
      goarch:
        - amd64
archives:
  - id: windows-tray
    builds:
        - windows-tray
    format: zip
    name_template: >-
      {{ .ProjectName }}_{{ .Version }}_TrayIcon_
      {{- if eq .Os "darwin" }}macOS
      {{- else }}{{- title .Os }}{{ end }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else }}{{ .Arch }}{{ end }}
  - id: linux-tray
    builds:
        - linux-tray
    format: zip
    name_template: >-
      {{ .ProjectName }}_{{ .Version }}_TrayIcon_
      {{- if eq .Os "darwin" }}macOS
      {{- else }}{{- title .Os }}{{ end }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else }}{{ .Arch }}{{ end }}
  - id: notray
    builds:
        - notray
    format: zip
    name_template: >-
      {{ .ProjectName }}_{{ .Version }}_
      {{- if eq .Os "darwin" }}macOS
      {{- else }}{{- title .Os }}{{ end }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else }}{{ .Arch }}{{ end }}
  - id: notray-e2ee
    builds:
        - notray-e2ee
    format: zip
    name_template: >-
      {{ .ProjectName }}_{{ .Version }}_MatrixE2EE_
      {{- if eq .Os "darwin" }}macOS
      {{- else }}{{- title .Os }}{{ end }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else }}{{ .Arch }}{{ end }}
checksum:
    name_template: 'checksums.txt'
snapshot:
    name_template: "0.0.0-{{ .Env.JFA_GO_NFPM_EPOCH }}"
changelog:
    sort: asc
    filters:
        exclude:
            - '^docs:'
            - '^test:'
nfpms:
  - id: notray
    file_name_template: '{{ .ProjectName }}{{ if .IsSnapshot }}-git{{ end }}_{{ .Arch }}_{{ if .IsSnapshot }}{{ .ShortCommit }}{{ else }}v{{ .Version }}{{ end }}'
    package_name: jfa-go
    homepage: https://github.com/hrfee/jfa-go
    description: A web app for managing users on Jellyfin
    maintainer: Harvey Tindall <hrfee@hrfee.dev>
    license: MIT
    vendor: hrfee.dev
    version_metadata: git
    builds:
      - notray-e2ee
    contents:
      - src: ./LICENSE
        dst: /usr/share/licenses/jfa-go
    formats:
      - apk
      - deb
      - rpm
    overrides:
        deb:
            dependencies:
                - libolm-dev
        rpm:
            dependencies:
                - libolm 
        apk:
            dependencies:
                - olm
  - id: tray
    file_name_template: '{{ .ProjectName }}{{ if .IsSnapshot }}-git{{ end }}_TrayIcon_{{ .Arch }}_{{ if .IsSnapshot }}{{ .ShortCommit }}{{ else }}v{{ .Version }}{{ end }}'
    package_name: jfa-go-tray
    homepage: https://github.com/hrfee/jfa-go
    description: A web app for managing users on Jellyfin
    maintainer: Harvey Tindall <hrfee@hrfee.dev>
    license: MIT
    vendor: hrfee.dev
    version_metadata: git
    builds:
      - linux-tray
    contents:
      - src: ./LICENSE
        dst: /usr/share/licenses/jfa-go
    formats:
      - apk
      - deb
      - rpm
    overrides:
        deb:
            conflicts:
                - jfa-go
            replaces:
                - jfa-go
            dependencies:
                - libayatana-appindicator
                - libolm-dev
        rpm:
            dependencies:
                - libappindicator-gtk3
                - libolm 
        apk:
            dependencies:
                - libayatana-appindicator
                - olm
