builds:
  - id: "hcloud-build"
    main: ./cmd/hcloud/main.go
    binary: hcloud
    ldflags:
      - -w -X github.com/hetznercloud/cli/internal/version.Version={{.Version}}
    env:
      - CGO_ENABLED=0
    goos:
      - freebsd
      - windows
      - linux
    goarch:
      - amd64
      - arm
      - arm64
      - 386
    goarm:
      - 6
      - 7

  - id: "hcloud-macos-build"
    main: ./cmd/hcloud/main.go
    binary: hcloud
    ldflags:
      - -w -X github.com/hetznercloud/cli/internal/version.Version={{.Version}}
    env:
      - CGO_ENABLED=0
    goos:
      - darwin
    goarch:
      - amd64
  - id: "hcloud-macos-arm-build"
    main: ./cmd/hcloud/main.go
    binary: hcloud
    ldflags:
      - -w -X github.com/hetznercloud/cli/internal/version.Version={{.Version}}
    env:
      - CGO_ENABLED=0
    goos:
      - darwin
    goarch:
      - arm64

before:
  hooks:
    - go mod tidy

checksum:
  name_template: "checksums.txt"
  algorithm: sha256

release:
  draft: true
  name_template: "hcloud v{{.Version}}"

signs:
  - ids:
      - hcloud-macos-build
    cmd: gon
    args:
      - -log-json
      - gon.hcl
    artifacts: all
    signature: "hcloud-macos-amd64.zip"
    id: hcloud-macos-sign
  - ids:
      - hcloud-macos-build-arm64
    cmd: gon
    args:
      - -log-json
      - gon_arm64.hcl
    artifacts: all
    signature: "hcloud-macos-arm64.zip"
    id: hcloud-macos-sign-arm64
  - artifacts: all
    signature: "${artifact}.sig"
    id: hcloud-sign
    ids:
      - hcloud-build
    args: ["--batch", "-u", "github-bot@hetzner-cloud.de", "--pinentry-mode", "loopback", "--output", "${signature}", "--detach-sign", "${artifact}"]

archives:
  - id: hcloud-archive
    builds:
      - hcloud-build
    name_template: "{{ .Binary }}-{{ .Os }}-{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"

    format_overrides:
      - goos: windows
        format: zip

    files:
      - LICENSE
      - CHANGES.md
      - README.md
