# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com
# before:
#   hooks:
#     # You may remove this if you don't use go modules.
#     - cd cli && go mod tidy
#     # you may remove this if you don't need go generate
#     - cd cli && go generate ./...
before:
  hooks:
    - ./cli/scripts/completions.sh
    - ./cli/scripts/manpages.sh

monorepo:
  tag_prefix: infisical-cli/
  dir: cli

builds:
  - id: darwin-build
    binary: infisical
    ldflags:
      - -X github.com/Infisical/infisical-merge/packages/util.CLI_VERSION={{ .Version }}
      - -X github.com/Infisical/infisical-merge/packages/telemetry.POSTHOG_API_KEY_FOR_CLI={{ .Env.POSTHOG_API_KEY_FOR_CLI }}
    flags:
      - -trimpath
    env:
      - CGO_ENABLED=1
      - CC=/home/runner/work/osxcross/target/bin/o64-clang
      - CXX=/home/runner/work/osxcross/target/bin/o64-clang++
    goos:
      - darwin
    ignore:
      - goos: darwin
        goarch: "386"
    dir: ./cli

  - id: all-other-builds
    env:
      - CGO_ENABLED=0
    binary: infisical
    ldflags:
      - -X github.com/Infisical/infisical-merge/packages/util.CLI_VERSION={{ .Version }}
      - -X github.com/Infisical/infisical-merge/packages/telemetry.POSTHOG_API_KEY_FOR_CLI={{ .Env.POSTHOG_API_KEY_FOR_CLI }}
    flags:
      - -trimpath
    goos:
      - freebsd
      - linux
      - netbsd
      - openbsd
      - windows
    goarch:
      - "386"
      - amd64
      - arm
      - arm64
    goarm:
      - "6"
      - "7"
    ignore:
      - goos: windows
        goarch: "386"
      - goos: freebsd
        goarch: "386"
    dir: ./cli

archives:
  - format_overrides:
      - goos: windows
        format: zip
    files:
      - ../README*
      - ../LICENSE*
      - ../manpages/*
      - ../completions/*

release:
  replace_existing_draft: true
  mode: "replace"

checksum:
  name_template: "checksums.txt"

snapshot:
  name_template: "{{ .Version }}-devel"

# publishers:
#   - name: fury.io
#     ids:
#       - infisical
#     dir: "{{ dir .ArtifactPath }}"
#     cmd: curl -F package=@{{ .ArtifactName }} https://{{ .Env.FURY_TOKEN }}@push.fury.io/infisical/

brews:
  - name: infisical
    tap:
      owner: Infisical
      name: homebrew-get-cli
    commit_author:
      name: "Infisical"
      email: ai@infisical.com
    folder: Formula
    homepage: "https://infisical.com"
    description: "The official Infisical CLI"
    install: |-
      bin.install "infisical"
      bash_completion.install "completions/infisical.bash" => "infisical"
      zsh_completion.install "completions/infisical.zsh" => "_infisical"
      fish_completion.install "completions/infisical.fish"
      man1.install "manpages/infisical.1.gz"

nfpms:
  - id: infisical
    package_name: infisical
    builds:
      - all-other-builds
    vendor: Infisical, Inc
    homepage: https://infisical.com/
    maintainer: Infisical, Inc
    description: The offical Infisical CLI
    license: MIT
    formats:
      - rpm
      - deb
      - apk
      - archlinux
    bindir: /usr/bin
    contents:
      - src: ./completions/infisical.bash
        dst: /etc/bash_completion.d/infisical
      - src: ./completions/infisical.fish
        dst: /usr/share/fish/vendor_completions.d/infisical.fish
      - src: ./completions/infisical.zsh
        dst: /usr/share/zsh/site-functions/_infisical
      - src: ./manpages/infisical.1.gz
        dst: /usr/share/man/man1/infisical.1.gz

scoop:
  bucket:
    owner: Infisical
    name: scoop-infisical
  commit_author:
    name: "Infisical"
    email: ai@infisical.com
  homepage: "https://infisical.com"
  description: "The official Infisical CLI"
  license: MIT

aurs:
  - name: infisical-bin
    homepage: "https://infisical.com"
    description: "The official Infisical CLI"
    maintainers:
      - Infisical, Inc <support@infisical.com>
    license: MIT
    private_key: "{{ .Env.AUR_KEY }}"
    git_url: "ssh://aur@aur.archlinux.org/infisical-bin.git"
    package: |-
      # bin
      install -Dm755 "./infisical" "${pkgdir}/usr/bin/infisical"
      # license
      install -Dm644 "./LICENSE" "${pkgdir}/usr/share/licenses/infisical/LICENSE"
      # completions
      mkdir -p "${pkgdir}/usr/share/bash-completion/completions/"
      mkdir -p "${pkgdir}/usr/share/zsh/site-functions/"
      mkdir -p "${pkgdir}/usr/share/fish/vendor_completions.d/"
      install -Dm644 "./completions/infisical.bash" "${pkgdir}/usr/share/bash-completion/completions/infisical"
      install -Dm644 "./completions/infisical.zsh" "${pkgdir}/usr/share/zsh/site-functions/_infisical"
      install -Dm644 "./completions/infisical.fish" "${pkgdir}/usr/share/fish/vendor_completions.d/infisical.fish"
      # man pages
      install -Dm644 "./manpages/infisical.1.gz" "${pkgdir}/usr/share/man/man1/infisical.1.gz"

# dockers:
#   - dockerfile: cli/docker/Dockerfile
#     goos: linux
#     goarch: amd64
#     ids:
#       - infisical
#     image_templates:
#       - "infisical/cli:{{ .Version }}"
#       - "infisical/cli:latest"
