# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
  hooks:
    - rustup default stable
    - cargo install --locked cargo-zigbuild
    - cargo fetch --locked

builds:
  - builder: rust
    flags:
      - --release
    targets:
      - x86_64-unknown-linux-musl
      - x86_64-apple-darwin
      - x86_64-pc-windows-gnu
      - aarch64-unknown-linux-musl
      - aarch64-apple-darwin

archives:
  - formats: [tar.gz]
    # this name template makes the OS and Arch compatible with the results of `uname`.
    name_template: >-
      {{ .ProjectName }}_
      {{- .Os }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else if eq .Arch "386" }}i386
      {{- else }}{{ .Arch }}{{ end }}
    # use zip for windows archives
    format_overrides:
      - goos: windows
        formats: [zip]

brews:
  - repository:
      owner: sh-cho
      name: homebrew-tap
      token: "{{ .Env.TAP_APP_TOKEN }}"
    directory: Formula
    homepage: "https://github.com/sh-cho/idt"
    description: "A fast, ergonomic CLI tool for working with various ID formats"
    # goreleaser currently doesn't support multilicense :(
    license: "MIT"
    extra_install: |
      generate_completions_from = proc do |shell|
        IO.popen("#{bin}/idt completions #{shell}", &:read)
      end
      (bash_completion/"idt").write generate_completions_from.call("bash")
      (zsh_completion/"_idt").write generate_completions_from.call("zsh")
      (fish_completion/"idt.fish").write generate_completions_from.call("fish")
    test: |
      system "#{bin}/idt", "--version"
    commit_author:
      name: github-actions[bot]
      email: 41898282+github-actions[bot]@users.noreply.github.com

checksum:
  split: true

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

release:
  footer: >-

    ---

    Released by [GoReleaser](https://github.com/goreleaser/goreleaser).
