project_name: chezmoi

before:
  hooks:
  - assets/scripts/generate-commit.sh -o COMMIT
  - go mod download all

builds:
- id: chezmoi-cgo-glibc
  env:
  - CGO_ENABLED=1
  goos:
  - linux
  goarch:
  - amd64
  ldflags:
  - -s
  - -w
  - -X main.version={{ .Version }}
  - -X main.commit={{ .Commit }}
  - -X main.date={{ .Date }}
  - -X main.builtBy=goreleaser
- id: chezmoi-cgo-musl
  env:
  - CC=/usr/bin/musl-gcc
  - CGO_ENABLED=1
  goos:
  - linux
  goarch:
  - amd64
  ldflags:
  - -s
  - -w
  - -X main.version={{ .Version }}
  - -X main.commit={{ .Commit }}
  - -X main.date={{ .Date }}
  - -X main.builtBy=goreleaser
  - -linkmode external
  - --extldflags "-static"
- id: chezmoi-nocgo
  env:
  - CGO_ENABLED=0
  goos:
  - darwin
  - freebsd
  - illumos
  - linux
  - openbsd
  - solaris
  - windows
  goarch:
  - '386'
  - amd64
  - arm
  - arm64
  - loong64
  - mips64
  - mips64le
  - ppc64
  - ppc64le
  - riscv64
  - s390x
  goarm:
  - ''
  ldflags:
  - -s
  - -w
  - -X main.version={{ .Version }}
  - -X main.commit={{ .Commit }}
  - -X main.date={{ .Date }}
  - -X main.builtBy=goreleaser
  ignore:
  - goos: darwin
    goarch: '386'
  - goos: linux
    goarch: amd64

archives:
- builds:
  - chezmoi-cgo-glibc # Required for chezmoi upgrade for versions <= 2.0.5
  - chezmoi-nocgo
  files:
  - LICENSE
  - README.md
  - completions/*
  replacements:
    386: i386
  format_overrides:
  - goos: windows
    format: zip
- id: glibc
  builds:
  - chezmoi-cgo-glibc
  files:
  - LICENSE
  - README.md
  - completions/*
  name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}-glibc_{{ .Arch }}'
- id: musl
  builds:
  - chezmoi-cgo-musl
  files:
  - LICENSE
  - README.md
  - completions/*
  name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}-musl_{{ .Arch }}'

changelog:
  use: github-native

checksum:
  extra_files:
  - glob: ./dist/chezmoi-nocgo_darwin_amd64_v1/chezmoi
    name_template: chezmoi-darwin-amd64
  - glob: ./dist/chezmoi-nocgo_darwin_arm64/chezmoi
    name_template: chezmoi-darwin-arm64
  - glob: ./dist/chezmoi-cgo-glibc_linux_amd64_v1/chezmoi
    name_template: chezmoi-linux-amd64
  - glob: ./dist/chezmoi-cgo-musl_linux_amd64_v1/chezmoi
    name_template: chezmoi-linux-amd64-musl
  - glob: ./dist/chezmoi-nocgo_windows_amd64_v1/chezmoi.exe
    name_template: chezmoi-windows-amd64.exe

nfpms:
- builds:
  - chezmoi-cgo-glibc
  - chezmoi-nocgo
  vendor: Tom Payne <twpayne@gmail.com>
  homepage: https://chezmoi.io/
  maintainer: Tom Payne <twpayne@gmail.com>
  description: Manage your dotfiles across multiple diverse machines, securely.
  license: MIT
  formats:
  - deb
  - rpm
  dependencies:
  - git
  bindir: /usr/bin
  overrides:
    deb:
      file_name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
      replacements:
        386: i386
        arm: armel
      contents:
      - src: completions/chezmoi-completion.bash
        dst: /usr/share/bash-completion/completions/chezmoi
      - src: completions/chezmoi.fish
        dst: /usr/share/fish/completions/chezmoi.fish
      - src: completions/chezmoi.zsh
        dst: /usr/share/zsh/vendor-completions/_chezmoi
    rpm:
      file_name_template: '{{ .ProjectName }}-{{ .Version }}-{{ .Arch }}'
      replacements:
        amd64: x86_64
        386: i686
        arm: armhfp
        arm64: aarch64
      contents:
      - src: completions/chezmoi-completion.bash
        dst: /usr/share/bash-completion/completions/chezmoi
      - src: completions/chezmoi.fish
        dst: /usr/share/fish/completions/chezmoi.fish
      - src: completions/chezmoi.zsh
        dst: /usr/share/zsh/site-functions/_chezmoi
- id: apks
  builds:
  - chezmoi-cgo-musl
  - chezmoi-nocgo
  vendor: Tom Payne <twpayne@gmail.com>
  homepage: https://chezmoi.io/
  maintainer: Tom Payne <twpayne@gmail.com>
  description: Manage your dotfiles across multiple diverse machines, securely.
  license: MIT
  formats:
  - apk
  bindir: /usr/bin

release:
  extra_files:
  - glob: ./assets/cosign/cosign.pub
    name_template: chezmoi_cosign.pub
  - glob: ./dist/chezmoi-nocgo_darwin_amd64_v1/chezmoi
    name_template: chezmoi-darwin-amd64
  - glob: ./dist/chezmoi-nocgo_darwin_arm64/chezmoi
    name_template: chezmoi-darwin-arm64
  - glob: ./dist/chezmoi-cgo-glibc_linux_amd64_v1/chezmoi
    name_template: chezmoi-linux-amd64
  - glob: ./dist/chezmoi-cgo-musl_linux_amd64_v1/chezmoi
    name_template: chezmoi-linux-amd64-musl
  - glob: ./dist/chezmoi-nocgo_windows_amd64_v1/chezmoi.exe
    name_template: chezmoi-windows-amd64.exe

scoop:
  bucket:
    owner: twpayne
    name: scoop-bucket
    token: '{{ .Env.SCOOP_GITHUB_TOKEN }}'
  commit_author:
    name: Tom Payne
    email: twpayne@gmail.com
  homepage: https://chezmoi.io
  description: Manage your dotfiles across multiple diverse machines, securely.
  license: MIT

signs:
- cmd: cosign
  stdin: '{{ .Env.COSIGN_PWD }}'
  args:
  - sign-blob
  - --key=assets/cosign/cosign.key
  - --output-signature=${signature}
  - ${artifact}
  artifacts: checksum

snapcrafts:
- builds:
  - chezmoi-cgo-glibc
  - chezmoi-nocgo
  summary: Manage your dotfiles across multiple diverse machines, securely.
  description: Manage your dotfiles across multiple diverse machines, securely.
  publish: true
  grade: stable
  confinement: classic
  license: MIT
  apps:
    chezmoi:
      command: chezmoi
      completer: completions/chezmoi-completion.bash

source:
  enabled: true
  prefix_template: '{{ .ProjectName }}-{{ .Version }}/'
  files:
  - COMMIT
