version: 2

project_name: k9s

before:
  hooks:
    - go mod download
    - go generate ./...

release:
  prerelease: false

env:
  - CGO_ENABLED=0

builds:
  - id: linux
    goos:
      - linux
    goarch:
      - amd64
      - arm64
      - arm
      - ppc64le
      - s390x
    goarm:
      - 7
    flags:
      - -trimpath
    ldflags:
      - -s -w -X github.com/derailed/k9s/cmd.version=v{{.Version}}
      - -s -w -X github.com/derailed/k9s/cmd.commit={{.Commit}}
      - -s -w -X github.com/derailed/k9s/cmd.date={{.Date}}

  - id: freebsd
    goos:
      - freebsd
    goarch:
      - amd64
      - arm64
    goarm:
      - 7
    flags:
      - -trimpath
    ldflags:
      - -s -w -X github.com/derailed/k9s/cmd.version=v{{.Version}}
      - -s -w -X github.com/derailed/k9s/cmd.commit={{.Commit}}
      - -s -w -X github.com/derailed/k9s/cmd.date={{.Date}}

  - id: osx
    goos:
      - darwin
    goarch:
      - amd64
      - arm64
    flags:
      - -trimpath
    ldflags:
      - -s -w -X github.com/derailed/k9s/cmd.version=v{{.Version}}
      - -s -w -X github.com/derailed/k9s/cmd.commit={{.Commit}}
      - -s -w -X github.com/derailed/k9s/cmd.date={{.Date}}

  - id: windows
    goos:
      - windows
    goarch:
      - amd64
      - arm64
    flags:
      - -trimpath
    ldflags:
      - -s -w -X github.com/derailed/k9s/cmd.version=v{{.Version}}
      - -s -w -X github.com/derailed/k9s/cmd.commit={{.Commit}}
      - -s -w -X github.com/derailed/k9s/cmd.date={{.Date}}

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

checksum:
  name_template: "checksums.sha256"

snapshot:
  version_template: "{{ .Tag }}-next"

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

brews:
  - name: k9s
    repository:
      owner: derailed
      name: homebrew-k9s
    commit_author:
      name: derailed
      email: fernand@imhotep.io
    directory: Formula
    homepage: https://k9scli.io/
    description: Kubernetes CLI To Manage Your Clusters In Style!
    test: |
      system "k9s version"

nfpms:
  - file_name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}'
    maintainer: Fernand Galiana
    homepage: https://k9scli.io
    description: Kubernetes CLI To Manage Your Clusters In Style!
    license: "Apache-2.0"
    formats:
      - deb
      - rpm
      - apk
    bindir: /usr/bin
    section: utils
    contents:
      - src: ./LICENSE
        dst: /usr/share/doc/k9s/copyright
        file_info:
          mode: 0644

sboms:
  - artifacts: archive