version: 2
project_name: troubleshoot

release:
  prerelease: auto

builds:
  - id: preflight
    main: ./cmd/preflight/main.go
    env: [CGO_ENABLED=0]
    goos: [linux, darwin, windows]
    goarch: [amd64, arm, arm64, riscv64]
    ignore:
      - goos: windows
        goarch: arm
      - goos: windows
        goarch: riscv64
      - goos: darwin
        goarch: riscv64
    ldflags:
      - -s -w
      - -X github.com/replicatedhq/troubleshoot/pkg/version.version={{ .Version }}
      - -X github.com/replicatedhq/troubleshoot/pkg/version.gitSHA={{ .Commit }}
      - -X github.com/replicatedhq/troubleshoot/pkg/version.buildTime={{ .Date }}
      - -extldflags "-static"
    flags:
      - -tags=netgo
      - -tags=containers_image_ostree_stub
      - -tags=exclude_graphdriver_devicemapper
      - -tags=exclude_graphdriver_btrfs
      - -tags=containers_image_openpgp
      - -installsuffix=netgo
    binary: preflight

  - id: support-bundle
    main: ./cmd/troubleshoot/main.go
    env: [CGO_ENABLED=0]
    goos: [linux, darwin, windows]
    goarch: [amd64, arm, arm64, riscv64]
    ignore:
      - goos: windows
        goarch: arm
      - goos: windows
        goarch: riscv64
      - goos: darwin
        goarch: riscv64
    ldflags:
      - -s -w
      - -X github.com/replicatedhq/troubleshoot/pkg/version.version={{ .Version }}
      - -X github.com/replicatedhq/troubleshoot/pkg/version.gitSHA={{ .Commit }}
      - -X github.com/replicatedhq/troubleshoot/pkg/version.buildTime={{ .Date }}
      - -extldflags "-static"
    flags:
      - -tags=netgo
      - -tags=containers_image_ostree_stub
      - -tags=exclude_graphdriver_devicemapper
      - -tags=exclude_graphdriver_btrfs
      - -tags=containers_image_openpgp
      - -installsuffix=netgo
    binary: support-bundle

  - id: collect
    main: ./cmd/collect/main.go
    env: [CGO_ENABLED=0]
    goos: [linux, darwin, windows]
    goarch: [amd64, arm, arm64, riscv64]
    ignore:
      - goos: windows
        goarch: arm
      - goos: windows
        goarch: riscv64
      - goos: darwin
        goarch: riscv64
    ldflags:
      - -s -w
      - -X github.com/replicatedhq/troubleshoot/pkg/version.version={{ .Version }}
      - -X github.com/replicatedhq/troubleshoot/pkg/version.gitSHA={{ .Commit }}
      - -X github.com/replicatedhq/troubleshoot/pkg/version.buildTime={{ .Date }}
      - -extldflags "-static"
    flags:
      - -tags=netgo
      - -tags=containers_image_ostree_stub
      - -tags=exclude_graphdriver_devicemapper
      - -tags=exclude_graphdriver_btrfs
      - -tags=containers_image_openpgp
      - -installsuffix=netgo
    binary: collect

archives:
  - id: preflight
    ids: [preflight]
    formats: [tar.gz]
    format_overrides:
      - goos: windows
        formats: [zip]
    name_template: "preflight_{{ .Os }}_{{ .Arch }}"
    files:
      - licence*
      - LICENCE*
      - license*
      - LICENSE*
      - readme*
      - README*
      - changelog*
      - CHANGELOG*
      - src: "sbom/assets/*"
        dst: .
        strip_parent: true
  - id: support-bundle
    ids: [support-bundle]
    formats: [tar.gz]
    format_overrides:
      - goos: windows
        formats: [zip]
    name_template: "support-bundle_{{ .Os }}_{{ .Arch }}"
    files:
      - licence*
      - LICENCE*
      - license*
      - LICENSE*
      - readme*
      - README*
      - changelog*
      - CHANGELOG*
      - src: "sbom/assets/*"
        dst: .
        strip_parent: true

  - id: preflight-universal
    ids: [preflight-universal]
    formats: [tar.gz]
    name_template: "preflight_{{ .Os }}_{{ .Arch }}"
    files:
      - licence*
      - LICENCE*
      - license*
      - LICENSE*
      - readme*
      - README*
      - changelog*
      - CHANGELOG*
      - src: "sbom/assets/*"
        dst: .
        strip_parent: true

  - id: support-bundle-universal
    ids: [support-bundle-universal]
    formats: [tar.gz]
    name_template: "support-bundle_{{ .Os }}_{{ .Arch }}"
    files:
      - licence*
      - LICENCE*
      - license*
      - LICENSE*
      - readme*
      - README*
      - changelog*
      - CHANGELOG*
      - src: "sbom/assets/*"
        dst: .
        strip_parent: true

dockers:
  - dockerfile: ./deploy/Dockerfile.troubleshoot
    image_templates:
      - "replicated/troubleshoot:latest"
      - "replicated/troubleshoot:{{ .Major }}"
      - "replicated/troubleshoot:{{ .Major }}.{{ .Minor }}"
      - "replicated/troubleshoot:{{ .Major }}.{{ .Minor }}.{{ .Patch }}"
    ids:
      - support-bundle
      - preflight
      - collect
  - dockerfile: ./deploy/Dockerfile.troubleshoot
    image_templates:
      - "replicated/preflight:latest"
      - "replicated/preflight:{{ .Major }}"
      - "replicated/preflight:{{ .Major }}.{{ .Minor }}"
      - "replicated/preflight:{{ .Major }}.{{ .Minor }}.{{ .Patch }}"
    ids:
      - support-bundle
      - preflight
      - collect

universal_binaries:
  - id: preflight-universal
    ids: [preflight]        # refers to the build id above
    replace: true
    name_template: preflight

  - id: support-bundle-universal
    ids: [support-bundle]   # refers to the build id above
    replace: true
    name_template: support-bundle

brews:
  - name: preflight
    ids: [preflight, preflight-universal]
    homepage: https://docs.replicated.com/reference/preflight-overview/
    description: "A preflight checker and conformance test for Kubernetes clusters."
    repository:
      owner: replicatedhq
      name: homebrew-replicated
      branch: main
    directory: HomebrewFormula
    install: bin.install "preflight"
  - name: support-bundle
    ids: [support-bundle, support-bundle-universal]
    homepage: https://docs.replicated.com/reference/support-bundle-overview/
    description: "Collect and redact support bundles for Kubernetes clusters."
    repository:
      owner: replicatedhq
      name: homebrew-replicated
      branch: main
    directory: HomebrewFormula
    install: bin.install "support-bundle"
