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

git:
  ignore_tags:
    - v0.0.0-prerelease
    # legacy date-based (CalVer) tags that semver-sort above the current v3.x
    # scheme; ignore so they can never be picked as the current/previous tag.
    - "v18.*"
    - "v19.*"
    - "v20.*"

before:
  hooks:
    - go mod tidy
    - go generate ./...
    - ./hack/make/completions
    - ./hack/make/manpages
    - ./hack/make/json_mini
    - ./hack/make/py_mini

snapshot:
  version_template: "{{ incpatch .Version }}-next"

# gomod:
#   proxy: true

report_sizes: true

metadata:
  mod_timestamp: "{{ .CommitTimestamp }}"

builds:
  # CLIs ###########################################################
  - id: darwin_build
    main: ./cmd/ipsw
    binary: ipsw
    env:
      - CGO_ENABLED=1
    goos:
      - darwin
    goarch:
      - amd64
      - arm64
    tags:
      - sandbox
    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}}
  - id: darwin_ios_build
    main: ./cmd/ipsw
    binary: ipsw
    env:
      - CGO_ENABLED=1
      - CC=$PWD/hack/make/clangwrap
    goos:
      - ios
    goarch:
      - arm64
    # goarm64:
    #   - v8.9
    tags:
      - sandbox
    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}}
    hooks:
      post:
        - ./hack/make/codesign {{ .Path }}
  - id: darwin_extras_build
    main: ./cmd/ipsw
    binary: ipsw
    env:
      - CGO_ENABLED=1
      - CC=sandbox-exec -f $PWD/hack/goreleaser/profile.sb cc
      - >-
        {{- if eq .Arch "amd64" }}CGO_LDFLAGS=-L/usr/local/homebrew/lib -framework IOKit
        {{- else if eq .Arch "arm64" }}CGO_LDFLAGS=-L/opt/homebrew/lib -framework IOKit
        {{- end }}
      - >-
        {{- if eq .Arch "amd64" }}CGO_CFLAGS=-I/usr/local/homebrew/include
        {{- else if eq .Arch "arm64" }}CGO_CFLAGS=-I/opt/homebrew/include
        {{- end }}
    goos:
      - darwin
    goarch:
      - amd64
      - arm64
    tags:
      - libusb
      # - unicorn
      - objc
      - sandbox
      - wallpaper
    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}}
    hooks:
      post:
        - ./hack/make/delete-all-rpaths {{ .Path }}
  - id: darwin_frida_build
    main: ./cmd/ipsw
    binary: ipsw
    env:
      - CGO_ENABLED=1
      - CGO_LDFLAGS=-L/usr/local/homebrew/lib
      - CGO_CFLAGS=-I{{ .Env.PWD }}/hack/frida-compat -I/usr/local/homebrew/include
      - >-
        {{- if eq .Arch "amd64" }}CGO_LDFLAGS=-L/usr/local/homebrew/lib
        {{- else if eq .Arch "arm64" }}CGO_LDFLAGS=-L/opt/homebrew/lib
        {{- end }}
      - >-
        {{- if eq .Arch "amd64" }}CGO_CFLAGS=-I{{ .Env.PWD }}/hack/frida-compat -I/usr/local/homebrew/include
        {{- else if eq .Arch "arm64" }}CGO_CFLAGS=-I{{ .Env.PWD }}/hack/frida-compat -I/opt/homebrew/include
        {{- end }}
    goos:
      - darwin
    goarch:
      - amd64
      - arm64
    tags:
      - frida
      - libusb
      - sandbox
    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}}
    hooks:
      post:
        - ./hack/make/delete-all-rpaths {{ .Path }}
  - id: linux_build
    main: ./cmd/ipsw
    binary: ipsw
    env:
      - CGO_ENABLED=1
      - >-
        {{- if eq .Arch "amd64" }}CC=zig cc -target x86_64-linux-musl
        {{- else if eq .Arch "arm64" }}CC=zig cc -target aarch64-linux-musl
        {{- end }}
      - >-
        {{- if eq .Arch "amd64" }}CXX=zig cc -target x86_64-linux-musl
        {{- else if eq .Arch "arm64" }}CXX=zig cc -target aarch64-linux-musl
        {{- end }}
    goos:
      - linux
    goarch:
      - amd64
      - arm64
    tags:
      - sandbox
    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}}
  # - id: linux_amd64_extras_build
  #   hooks:
  #     pre:
  #       - hack/make/libusb x86_64
  #       - hack/make/unicorn x86_64
  #     post:
  #       - /opt/homebrew/opt/llvm/bin/llvm-strip {{ .Path }}
  #   main: ./cmd/ipsw
  #   binary: ipsw
  #   env:
  #     - CGO_ENABLED=1
  #     - CC=zig cc -target x86_64-linux-musl
  #     - CXX=zig c++ -target x86_64-linux-musl
  #     - CGO_LDFLAGS=-L/tmp/install_x86_64/usr/local/lib
  #     - PKG_CONFIG_PATH=/tmp/install_x86_64/usr/local/lib/pkgconfig
  #     - CGO_CFLAGS=-I/tmp/install_x86_64/usr/local/include/libusb-1.0 -I/tmp/install_x86_64/usr/local/include
  #   tags:
  #     - libusb
  #     - unicorn
  #   goos:
  #     - linux
  #   goarch:
  #     - amd64
  #   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}}
  # - id: linux_arm64_extras_build
  #   hooks:
  #     pre:
  #       - hack/make/libusb aarch64
  #       - hack/make/unicorn aarch64
  #     post:
  #       - /opt/homebrew/opt/llvm/bin/llvm-strip {{ .Path }}
  #   main: ./cmd/ipsw
  #   binary: ipsw
  #   env:
  #     - CGO_ENABLED=1
  #     - CC=zig cc -target aarch64-linux-musl
  #     - CXX=zig c++ -target aarch64-linux-musl
  #     - CGO_LDFLAGS=-L/tmp/install_aarch64/usr/local/lib
  #     - PKG_CONFIG_PATH=/tmp/install_aarch64/usr/local/lib/pkgconfig
  #     - CGO_CFLAGS=-I/tmp/install_aarch64/usr/local/include/libusb-1.0 -I/tmp/install_aarch64/usr/local/include
  #   tags:
  #     - libusb
  #     - unicorn
  #   goos:
  #     - linux
  #   goarch:
  #     - 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}}
  - id: windows_build
    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
    tags:
      - sandbox
    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}}
  # DAEMONS ###########################################################
  - id: darwin_daemon_build
    main: ./cmd/ipswd
    binary: ipswd
    env:
      - CGO_ENABLED=1
    goos:
      - darwin
    goarch:
      - amd64
      - arm64
    tags:
      - sandbox
    mod_timestamp: "{{ .CommitTimestamp }}"
    flags:
      - -trimpath
    ldflags: -s -w -X github.com/blacktop/ipsw/api/types.BuildVersion={{.Version}} -X github.com/blacktop/ipsw/api/types.BuildTime={{.Commit}}
  - id: linux_daemon_build
    main: ./cmd/ipswd
    binary: ipswd
    env:
      - CGO_ENABLED=1
      - >-
        {{- if eq .Arch "amd64" }}CC=zig cc -target x86_64-linux-musl
        {{- else if eq .Arch "arm64" }}CC=zig cc -target aarch64-linux-musl
        {{- end }}
      - >-
        {{- if eq .Arch "amd64" }}CXX=zig cc -target x86_64-linux-musl
        {{- else if eq .Arch "arm64" }}CXX=zig cc -target aarch64-linux-musl
        {{- end }}
    goos:
      - linux
    goarch:
      - amd64
      - arm64
    tags:
      - sandbox
    mod_timestamp: "{{ .CommitTimestamp }}"
    flags:
      - -trimpath
    ldflags: -s -w -X github.com/blacktop/ipsw/api/types.BuildVersion={{.Version}} -X github.com/blacktop/ipsw/api/types.BuildTime={{.Commit}}
  - id: windows_daemon_build
    main: ./cmd/ipswd
    binary: ipswd
    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
    tags:
      - sandbox
    mod_timestamp: "{{ .CommitTimestamp }}"
    flags:
      - -trimpath
    ldflags: -s -w -X github.com/blacktop/ipsw/api/types.BuildVersion={{.Version}} -X github.com/blacktop/ipsw/api/types.BuildTime={{.Commit}}

universal_binaries:
  - id: darwin_build
    replace: false
  - id: darwin_daemon_build
    replace: false

archives:
  - id: default_archive
    ids:
      - darwin_build
      - darwin_ios_build
      - darwin_universal
      - linux_build
      - windows_build
    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
        formats: zip
    builds_info:
      group: root
      owner: root
    files:
      - README.md
      - LICENSE
      - completions/ipsw/*
      - manpages/*
      - config.example.yml
  - id: extras_archive
    ids:
      - darwin_extras_build
      # - linux_amd64_extras_build
      # - linux_arm64_extras_build
    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 }}_extras
    files:
      - README.md
      - LICENSE
      - completions/ipsw/*
      - manpages/*
      - config.example.yml
  - id: frida_archive
    ids:
      - darwin_frida_build
    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 }}_frida
    files:
      - README.md
      - LICENSE
      - completions/ipsw/*
      - manpages/*
      - config.example.yml
  - id: daemon_archive
    ids:
      - darwin_daemon_build
      - linux_daemon_build
      - windows_daemon_build
    name_template: >-
      ipswd_{{ .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
        formats: zip
    builds_info:
      group: root
      owner: root
    files:
      - README.md
      - LICENSE
      - completions/ipswd/*
      - config.example.yml

brews:
  - repository:
      owner: blacktop
      name: homebrew-tap
    ids:
      - extras_archive
    directory: Formula
    homepage: "https://github.com/blacktop/ipsw"
    description: "iOS/macOS Research Swiss Army Knife"
    license: MIT
    dependencies:
      - name: bat
        type: optional
      - name: libusb
        type: optional
      - name: unicorn
        type: optional
      - name: git-delta
        type: optional
    conflicts:
      - ipsw-frida
    install: |
      bin.install "ipsw"
      prefix.install "LICENSE", "README.md", "config.example.yml"
      (etc/"ipsw").mkpath
      etc.install prefix/"config.example.yml" => "ipsw/config.yml"
      bash_completion.install "completions/ipsw/_bash" => "ipsw"
      zsh_completion.install "completions/ipsw/_zsh" => "_ipsw"
      fish_completion.install "completions/ipsw/_fish" => "ipsw.fish"
      man1.install Dir["manpages/*"]
    test: |
      system "#{bin}/ipsw version"
  - name: ipsw-frida
    repository:
      owner: blacktop
      name: homebrew-tap
    ids:
      - frida_archive
    directory: Formula
    homepage: "https://github.com/blacktop/ipsw"
    description: "iOS/macOS Research Swiss Army Knife"
    license: MIT
    dependencies:
      - name: bat
        type: optional
      - name: libusb
        type: optional
    conflicts:
      - ipsw
    install: |
      bin.install "ipsw"
      prefix.install "LICENSE", "README.md", "config.example.yml"
      (etc/"ipsw").mkpath
      etc.install prefix/"config.example.yml" => "ipsw/config.yml"
      bash_completion.install "completions/ipsw/_bash" => "ipsw"
      zsh_completion.install "completions/ipsw/_zsh" => "_ipsw"
      fish_completion.install "completions/ipsw/_fish" => "ipsw.fish"
      man1.install Dir["manpages/*"]
    test: |
      system "#{bin}/ipsw version"
  - name: ipswd
    repository:
      owner: blacktop
      name: homebrew-tap
    ids:
      - daemon_archive
    directory: Formula
    homepage: "https://github.com/blacktop/ipsw"
    description: "ipsw - Daemon"
    license: MIT
    dependencies:
      - name: libusb
        type: optional
    caveats: |
      By default, ipswd runs on localhost (127.0.0.1), port 3993.
      If you would like to change these settings, you will have to
      edit the configuration file:
        #{etc}/ipsw/config.yml

      To restart ipswd after an upgrade or config change:
        brew services restart ipswd
      Or, if you don't want/need a background service you can just run:
        /opt/homebrew/opt/ipswd/bin/ipswd start

      To see ipswd logs:
        tail -f /opt/homebrew/var/log/ipswd.log

      To remove ipswd:
        brew services stop ipswd
        brew uninstall ipswd
    install: |
      bin.install "ipswd"
      prefix.install "LICENSE", "README.md", "config.example.yml"
      (etc/"ipsw").mkpath
      etc.install prefix/"config.example.yml" => "ipsw/config.yml"
      bash_completion.install "completions/ipswd/_bash" => "ipswd"
      zsh_completion.install "completions/ipswd/_zsh" => "_ipswd"
      fish_completion.install "completions/ipswd/_fish" => "ipswd.fish"
    service: |
      run [opt_bin/"ipswd", "start", "--config", etc/"ipsw/config.yml"]
      environment_variables IPSW_IN_HOMEBREW: 1
      keep_alive true
      log_path var/"log/ipswd.log"
      error_log_path var/"log/ipswd.err.log"
      sockets "tcp://127.0.0.1:3993"
    test: |
      system "#{bin}/ipswd version"

homebrew_casks:
  - repository:
      owner: blacktop
      name: homebrew-tap
    ids:
      - extras_archive
    homepage: https://github.com/blacktop/ipsw
    description: iOS/macOS Research Swiss Army Knife
    license: MIT
    conflicts:
      - cask: ipsw-frida
    manpages:
      - "manpages/*"
    completions:
      bash: "completions/ipsw/_bash"
      zsh: "completions/ipsw/_zsh"
      fish: "completions/ipsw/_fish"
    url:
      verified: github.com/blacktop/ipsw/releases/download

checksum:
  name_template: "checksums.txt"

signs:
  - cmd: ssh-keygen
    args:
      - "-Y"
      - "sign"
      - "-f"
      - "{{ .Env.HOME }}/.ssh/id_ecdsa_sk_rk.pub"
      - "-n"
      - "file"
      - "${artifact}"
    signature: "${artifact}.sig"
    artifacts: checksum

sboms:
  - artifacts: archive

nix:
  - name: ipsw
    ids:
      - default_archive
    repository:
      owner: blacktop
      name: nur
    homepage: https://github.com/blacktop/ipsw
    description: iOS/macOS Research Swiss Army Knife
    path: pkgs/ipsw/default.nix
    license: mit
    extra_install: |-
      installManPage ./manpages/ipsw.1.gz
      installShellCompletion ./completions/ipsw/*

aurs:
  - ids:
      - default_archive
    homepage: https://github.com/blacktop/ipsw
    description: iOS/macOS Research Swiss Army Knife
    maintainers:
      - "Blacktop <https://github.com/blacktop>"
    license: MIT
    private_key: /Users/blacktop/.ssh/aur
    git_url: "ssh://aur@aur.archlinux.org/ipsw-bin.git"
    backup:
      - etc/ipsw.conf
    package: |-
      # bin
      install -Dm755 "./ipsw" "${pkgdir}/usr/bin/ipsw"

      # license
      install -Dm644 "./LICENSE" "${pkgdir}/usr/share/licenses/ipsw/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/ipsw/_bash" "${pkgdir}/usr/share/bash-completion/completions/ipsw"
      install -Dm644 "./completions/ipsw/_zsh" "${pkgdir}/usr/share/zsh/site-functions/_ipsw"
      install -Dm644 "./completions/ipsw/_fish" "${pkgdir}/usr/share/fish/vendor_completions.d/ipsw.fish"

      # man pages
      install -Dm644 "./manpages/ipsw.1.gz" "${pkgdir}/usr/share/man/man1/ipsw.1.gz"

      # config
      mkdir -p "${pkgdir}/etc"
      install -Dm644 "./config.example.yml" "${pkgdir}/etc/ipsw.conf"
  - ids:
      - daemon_archive
    name: ipswd
    homepage: https://github.com/blacktop/ipsw
    description: ipsw - Daemon
    maintainers:
      - "Blacktop <https://github.com/blacktop>"
    license: MIT
    private_key: /Users/blacktop/.ssh/aur
    git_url: "ssh://aur@aur.archlinux.org/ipswd-bin.git"
    backup:
      - etc/ipsw.conf
    package: |-
      # bin
      install -Dm755 "./ipswd" "${pkgdir}/usr/bin/ipswd"

      # license
      install -Dm644 "./LICENSE" "${pkgdir}/usr/share/licenses/ipswd/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/ipswd/_bash" "${pkgdir}/usr/share/bash-completion/completions/ipswd"
      install -Dm644 "./completions/ipswd/_zsh" "${pkgdir}/usr/share/zsh/site-functions/_ipswd"
      install -Dm644 "./completions/ipswd/_fish" "${pkgdir}/usr/share/fish/vendor_completions.d/ipswd.fish"

      # man pages
      install -Dm644 "./manpages/ipswd.1.gz" "${pkgdir}/usr/share/man/man1/ipswd.1.gz"

      # config
      mkdir -p "${pkgdir}/etc"
      install -Dm644 "./config.example.yml" "${pkgdir}/etc/ipsw.conf"

nfpms:
  - id: packages
    ids:
      - linux_build
    homepage: https://github.com/blacktop/ipsw
    description: |-
      iOS/macOS Research Swiss Army Knife.
    maintainer: Blacktop <https://github.com/blacktop>
    license: MIT
    vendor: Blacktop
    bindir: /usr/bin
    section: utils
    mtime: "{{ .CommitDate }}"
    contents:
      - src: ./config.example.yml
        dst: /etc/ipsw/config.yml
        type: config|noreplace
        file_info:
          mode: 0644
          mtime: "{{ .CommitDate }}"
      - src: ./completions/ipsw/_bash
        dst: /usr/share/bash-completion/completions/ipsw
        file_info:
          mode: 0644
          mtime: "{{ .CommitDate }}"
      - src: ./completions/ipsw/_zsh
        dst: /usr/share/zsh/vendor-completions/_ipsw
        file_info:
          mode: 0644
          mtime: "{{ .CommitDate }}"
      - src: ./completions/ipsw/_fish
        dst: /usr/share/fish/vendor_completions.d/ipsw.fish
        file_info:
          mode: 0644
          mtime: "{{ .CommitDate }}"
      - src: ./manpages/ipsw.1.gz
        dst: /usr/share/man/man1/ipsw.1.gz
        file_info:
          mode: 0644
          mtime: "{{ .CommitDate }}"
      - src: ./LICENSE
        dst: /usr/share/doc/ipsw/copyright
        file_info:
          mode: 0644
          mtime: "{{ .CommitDate }}"
    file_name_template: >-
      {{ .ProjectName }}_{{ .Version }}_
      {{- .Os }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else if eq .Arch "386" }}i386
      {{- else }}{{ .Arch }}{{ end }}
    formats:
      - deb
      - rpm
      - apk
      - archlinux
    deb:
      lintian_overrides:
        - statically-linked-binary
        - changelog-file-missing-in-native-package
  - id: daemon
    package_name: ipswd
    ids:
      - linux_daemon_build
    homepage: https://github.com/blacktop/ipsw
    description: |-
      ipsw daemon.
    maintainer: Blacktop <https://github.com/blacktop>
    license: MIT
    vendor: Blacktop
    bindir: /usr/bin
    section: utils
    mtime: "{{ .CommitDate }}"
    provides:
      - ipswd
    contents:
      - src: ./hack/goreleaser/linux_install/ipsw.service
        dst: /usr/lib/systemd/user/ipsws.service
        file_info:
          mode: 0644
      - src: ./config.example.yml
        dst: /etc/ipsw/config.yml
        type: config|noreplace
        file_info:
          mode: 0644
          mtime: "{{ .CommitDate }}"
      - src: ./completions/ipswd/_bash
        dst: /usr/share/bash-completion/completions/ipswd
        file_info:
          mode: 0644
          mtime: "{{ .CommitDate }}"
      - src: ./completions/ipswd/_zsh
        dst: /usr/share/zsh/vendor-completions/_ipswd
        file_info:
          mode: 0644
          mtime: "{{ .CommitDate }}"
      - src: ./completions/ipswd/_fish
        dst: /usr/share/fish/vendor_completions.d/ipswd.fish
        file_info:
          mode: 0644
          mtime: "{{ .CommitDate }}"
      - src: ./LICENSE
        dst: /usr/share/doc/ipsw/copyright
        file_info:
          mode: 0644
          mtime: "{{ .CommitDate }}"
    scripts:
      postinstall: "./hack/goreleaser/linux_install/postinstall.sh"
      postremove: "./hack/goreleaser/linux_install/postremove.sh"
    file_name_template: >-
      ipswd_{{ .Version }}_
      {{- .Os }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else if eq .Arch "386" }}i386
      {{- else }}{{ .Arch }}{{ end }}
    formats:
      - deb
      - rpm
      - apk
      - archlinux
    deb:
      lintian_overrides:
        - statically-linked-binary
        - changelog-file-missing-in-native-package

snapcrafts:
  - id: snaps
    ids:
      - linux_build
      # - linux_amd64_extras_build
      # - linux_arm64_extras_build
    summary: iOS/macOS Research Swiss Army Knife.
    description: |
      iOS/macOS Research Swiss Army Knife.
    grade: stable
    confinement: strict
    publish: true
    license: MIT
    extra_files:
      - source: ./completions/ipsw/_bash
        destination: /usr/share/completions
        mode: 0644
      - source: ./completions/ipsw/_zsh
        destination: /usr/share/completions
        mode: 0644
      - source: ./completions/ipsw/_fish
        destination: /usr/share/completions
        mode: 0644
      - source: ./manpages/ipsw.1.gz
        destination: /usr/share/man/man1/ipsw.1.gz
        mode: 0644
      - source: ./LICENSE
        destination: /usr/share/doc/ipsw/copyright
        mode: 0644
      - source: ./config.example.yml
        destination: /etc/ipsw/config.yml
        mode: 0644
    layout:
      # The path you want to access in sandbox.
      /etc/ipsw/config.yml:
        bind_file: $SNAP_DATA/etc/ipsw/config.yml
      /usr/share/bash-completion/completions/ipsw:
        bind_file: $SNAP_DATA/usr/share/completions/_bash
      /usr/share/zsh/vendor-completions/_ipsw:
        bind_file: $SNAP_DATA/usr/share/completions/_zsh
      /usr/share/fish/vendor_completions.d/ipsw.fish:
        bind_file: $SNAP_DATA/usr/share/completions/_fish
    apps:
      ipsw:
        command: ipsw
        plugs: ["home", "network", "fuse-support", "removable-media"]
  - id: snaps-daemon
    ids:
      - linux_daemon_build
    name: ipswd
    name_template: "ipswd-{{.Version}}-{{.Os}}-{{.Arch}}"
    summary: ipsw - Daemon.
    description: |
      ipsw - Daemon.
    grade: stable
    confinement: strict
    publish: true
    license: MIT
    extra_files:
      - source: ./hack/goreleaser/linux_install/ipswd.wrapper
        destination: /bin/ipswd.wrapper
        mode: 0755
      - source: ./completions/ipswd/_bash
        destination: /usr/share/completions/_bash
        mode: 0644
      - source: ./completions/ipswd/_zsh
        destination: /usr/share/completions/_zsh
        mode: 0644
      - source: ./completions/ipswd/_fish
        destination: /usr/share/completions/_fish
        mode: 0644
      - source: ./LICENSE
        destination: /usr/share/doc/ipsw/copyright
        mode: 0644
      - source: ./config.example.yml
        destination: /etc/ipsw/config.yml
        mode: 0644
    layout:
      # The path you want to access in sandbox.
      /usr/share/bash-completion/completions/ipswd:
        bind_file: $SNAP/usr/share/completions/_bash
      /usr/share/zsh/vendor-completions/_ipswd:
        bind_file: $SNAP/usr/share/completions/_zsh
      /usr/share/fish/vendor_completions.d/ipswd.fish:
        bind_file: $SNAP/usr/share/completions/_fish
    apps:
      ipswd:
        command: bin/ipswd.wrapper
        daemon: simple
        refresh_mode: restart
        restart_condition: "always"
        environment:
          IPSW_IN_SNAP: 1
          IPSW_DAEMON_SOCKET: $SNAP_COMMON/ipsw.sock
        sockets:
          sock:
            listen-stream: $SNAP_COMMON/ipsw.sock
            socket-mode: 0770
        plugs: ["home", "network", "network-bind", "removable-media"]

scoops:
  - ids: [default_archive]
    name: ipsw
    repository:
      owner: blacktop
      name: scoop-bucket
    homepage: https://blacktop.github.io/ipsw
    description: iOS/macOS Research Swiss Army Knife
    license: MIT
  - ids: [daemon_archive]
    name: ipswd
    repository:
      owner: blacktop
      name: scoop-bucket
    homepage: https://blacktop.github.io/ipsw
    description: ipsw - Daemon
    license: MIT

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

# chocolateys:
#   - project_url: https://github.com/blacktop/ipsw
#     icon_url: https://github.com/blacktop/ipsw/raw/master/docs/static/images/ipsw.png
#     license_url: https://github.com/blacktop/ipsw/blob/master/LICENSE
#     authors: blacktop
#     release_notes: "https://github.com/blacktop/ipsw/releases/tag/v{{ .Version }}"
#     copyright: 2018-2024 blacktop
#     project_source_url: https://github.com/blacktop/ipsw
#     docs_url: https://blacktop.github.io/ipsw/
#     summary: iOS/macOS Research Swiss Army Knife
#     description: Everything you need to do security research on iOS and macOS.
#     tags: "iOS macOS security research swiss-army-knife"

changelog:
  sort: asc
  use: github
  format: "{{ .SHA }}: {{ .Message }}{{ with .AuthorUsername }} (@{{ . }}){{ end }}"
  groups:
    - title: Dependency updates
      regexp: '^.*?(.+)\(deps\)!?:.+$'
      order: 300
    - title: "New Features"
      regexp: '^.*?feat(\(.+\))??!?:.+$'
      order: 100
    - title: "Security updates"
      regexp: '^.*?sec(\(.+\))??!?:.+$'
      order: 150
    - title: "Performance improvements"
      regexp: '^.*?perf(\(.+\))??!?:.+$'
      order: 175
    - title: "Bug fixes"
      regexp: '^.*?(fix|refactor)(\(.+\))??!?:.+$'
      order: 200
    - title: "Documentation updates"
      regexp: ^.*?docs?(\(.+\))??!?:.+$
      order: 400
    - title: "Build process updates"
      regexp: ^.*?(build|ci)(\(.+\))??!?:.+$
      order: 400
    - title: Other work
      order: 9999
  filters:
    include:
      - "^feat.*"
      - "^fix.*"
      - "^perf.*"
      - "^chore.*"
      - "^sec.*"
      - "^(doc|docs).*"

release:
  footer: |
    ### Summary
    **Full Changelog**: https://github.com/blacktop/ipsw/compare/{{ .PreviousTag }}...{{ .Tag }}
    ## What to do next?
    - Read the [documentation](https://blacktop.github.io/ipsw)
    - Follow us on [Twitter](https://twitter.com/blacktop__)
    - Follow us on [Mastodon](https://mastodon.social/@blacktop)
    - Follow us on [Bluesky](https://bsky.app/profile/blacktop.bsky.social)

announce:
  discord:
    enabled: false
    message_template: "`ipsw` {{ .Tag }} is out! Check it out: https://github.com/blacktop/ipsw/releases/tag/{{ .Tag }}"
  mastodon:
    enabled: false
    message_template: "`ipsw` {{ .Tag }} is out! Check it out: https://github.com/blacktop/ipsw/releases/tag/{{ .Tag }}"
    server: https://mastodon.social
  bluesky:
    enabled: true
    message_template: "`ipsw` {{ .Tag }} is out! Check it out: https://github.com/blacktop/ipsw/releases/tag/{{ .Tag }}"
    username: "ipsw-tool.bsky.social"
