# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
  hooks:
    # `go mod tidy` fails on public CI runners because internal/diff/sandbox.go
    # (//go:build sandbox) imports the closed-source pkg/sandbox/. tidy evaluates
    # all build tags. Use `go mod download` which only fetches what go.mod requires.
    - go mod download

builds:
  - id: windows
    main: ./cmd/ipsw
    binary: ipsw
    env:
      - CGO_ENABLED=1
      - >-
        {{- if eq .Arch "386" }}CC=zig cc -target i386-windows-gnu
        {{- else if eq .Arch "amd64" }}CC=zig cc -target x86_64-windows-gnu
        {{- else if eq .Arch "arm64" }}CC=zig cc -target aarch64-windows-gnu
        {{- end }}
      - >-
        {{- if eq .Arch "386" }}CXX=zig cc -target i386-windows-gnu
        {{- else if eq .Arch "amd64" }}CXX=zig cc -target x86_64-windows-gnu
        {{- else if eq .Arch "arm64" }}CXX=zig cc -target aarch64-windows-gnu
        {{- end }}
    goos:
      - windows
    goarch:
      - "386"
      - amd64
      - arm64
    mod_timestamp: "{{ .CommitTimestamp }}"
    flags:
      - -trimpath
    ldflags: -s -w -X github.com/blacktop/ipsw/cmd/ipsw/cmd.AppVersion={{.Version}} -X github.com/blacktop/ipsw/cmd/ipsw/cmd.AppBuildCommit={{.Commit}}

archives:
  - id: default_archive
    builds:
      - windows
    name_template: >-
      {{ .ProjectName }}_{{ .Version }}_
      {{- if eq .Os "darwin" }}macOS
      {{- else if eq .Os "ios" }}iOS
      {{- else }}{{ .Os }}{{ end }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else if eq .Arch "386" }}i386
      {{- else if eq .Arch "all" }}universal
      {{- else }}{{ .Arch }}{{ end }}
    format_overrides:
      - goos: windows
        format: zip
    builds_info:
      group: root
      owner: root
    files:
      - README.md
      - LICENSE
      - completions/ipsw/*
      - manpages/*
      - config.example.yml
    wrap_in_directory: true

checksum:
  name_template: "checksums.win.txt"

winget:
  - name: ipsw
    publisher: blacktop
    license: MIT
    homepage: https://github.com/blacktop/ipsw
    short_description: iOS/macOS Research Swiss Army Knife
    ids:
      - default_archive
    path: manifests/b/ipsw
    repository:
      owner: blacktop
      name: winget-pkgs
      branch: "ipsw-{{.Version}}"
      pull_request:
        enabled: true
        draft: true
        base:
          owner: microsoft
          name: winget-pkgs
          branch: master
