project_name: flux
changelog:
  use: github-native
builds:
  - <<: &build_defaults
      binary: flux
      main: ./cmd/flux
      ldflags:
        - -s -w -X main.VERSION={{ .Version }}
      env:
        - CGO_ENABLED=0
    id: linux
    goos:
      - linux
    goarch:
      - amd64
      - arm64
      - arm
    goarm:
      - "7"
  - <<: *build_defaults
    id: darwin
    goos:
      - darwin
    goarch:
      - amd64
      - arm64
  - <<: *build_defaults
    id: windows
    goos:
      - windows
archives:
  - name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
    id: nix
    builds: [linux, darwin]
    format: tar.gz
    files:
      - none*
  - name_template: "{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
    id: windows
    builds: [windows]
    format: zip
    files:
      - none*
source:
  enabled: true
  name_template: '{{ .ProjectName }}_{{ .Version }}_source_code'
sboms:
  - id: source
    artifacts: source
    documents:
      - "{{ .ProjectName }}_{{ .Version }}_sbom.spdx.json"
release:
  extra_files:
    - glob: output/crd-schemas.tar.gz
    - glob: output/manifests.tar.gz
    - glob: output/install.yaml
checksum:
  extra_files:
    - glob: output/crd-schemas.tar.gz
    - glob: output/manifests.tar.gz
    - glob: output/install.yaml
signs:
  - cmd: cosign
    env:
      - COSIGN_EXPERIMENTAL=1
    certificate: '${artifact}.pem'
    args:
      - sign-blob
      - "--yes"
      - '--output-certificate=${certificate}'
      - '--output-signature=${signature}'
      - '${artifact}'
    artifacts: checksum
    output: true
brews:
  - name: flux
    repository:
      owner: fluxcd
      name: homebrew-tap
      token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
    directory: Formula
    homepage: "https://fluxcd.io/"
    description: "Flux CLI"
    install: |
      bin.install "flux"

      generate_completions_from_executable(bin/"flux", "completion")
    test: |
      system "#{bin}/flux --version"
publishers:
  - name: aur-pkg-bin
    env:
      - AUR_BOT_SSH_PRIVATE_KEY={{ .Env.AUR_BOT_SSH_PRIVATE_KEY }}
    cmd: |
      .github/aur/flux-bin/publish.sh {{ .Version }}
  - name: aur-pkg-scm
    env:
      - AUR_BOT_SSH_PRIVATE_KEY={{ .Env.AUR_BOT_SSH_PRIVATE_KEY }}
    cmd: |
      .github/aur/flux-scm/publish.sh {{ .Version }}
  - name: aur-pkg-go
    env:
      - AUR_BOT_SSH_PRIVATE_KEY={{ .Env.AUR_BOT_SSH_PRIVATE_KEY }}
    cmd: |
      .github/aur/flux-go/publish.sh {{ .Version }}
dockers:
- image_templates:
    - 'fluxcd/flux-cli:{{ .Tag }}-amd64'
    - 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-amd64'
  dockerfile: Dockerfile
  use: buildx
  goos: linux
  goarch: amd64
  build_flag_templates:
   - "--pull"
   - "--build-arg=ARCH=linux/amd64"
   - "--label=org.opencontainers.image.created={{ .Date }}"
   - "--label=org.opencontainers.image.name={{ .ProjectName }}"
   - "--label=org.opencontainers.image.revision={{ .FullCommit }}"
   - "--label=org.opencontainers.image.version={{ .Version }}"
   - "--label=org.opencontainers.image.source={{ .GitURL }}"
   - "--platform=linux/amd64"
- image_templates:
    - 'fluxcd/flux-cli:{{ .Tag }}-arm64'
    - 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm64'
  dockerfile: Dockerfile
  use: buildx
  goos: linux
  goarch: arm64
  build_flag_templates:
    - "--pull"
    - "--build-arg=ARCH=linux/arm64"
    - "--label=org.opencontainers.image.created={{ .Date }}"
    - "--label=org.opencontainers.image.name={{ .ProjectName }}"
    - "--label=org.opencontainers.image.revision={{ .FullCommit }}"
    - "--label=org.opencontainers.image.version={{ .Version }}"
    - "--label=org.opencontainers.image.source={{ .GitURL }}"
    - "--platform=linux/arm64"
- image_templates:
    - 'fluxcd/flux-cli:{{ .Tag }}-arm'
    - 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm'
  dockerfile: Dockerfile
  use: buildx
  goos: linux
  goarch: arm
  goarm: 7
  build_flag_templates:
    - "--pull"
    - "--build-arg=ARCH=linux/arm"
    - "--label=org.opencontainers.image.created={{ .Date }}"
    - "--label=org.opencontainers.image.name={{ .ProjectName }}"
    - "--label=org.opencontainers.image.revision={{ .FullCommit }}"
    - "--label=org.opencontainers.image.version={{ .Version }}"
    - "--label=org.opencontainers.image.source={{ .GitURL }}"
    - "--platform=linux/arm/v7"
docker_manifests:
- name_template: 'fluxcd/flux-cli:{{ .Tag }}'
  image_templates:
    - 'fluxcd/flux-cli:{{ .Tag }}-amd64'
    - 'fluxcd/flux-cli:{{ .Tag }}-arm64'
    - 'fluxcd/flux-cli:{{ .Tag }}-arm'
- name_template: 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}'
  image_templates:
    - 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-amd64'
    - 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm64'
    - 'ghcr.io/fluxcd/flux-cli:{{ .Tag }}-arm'
docker_signs:
  - cmd: cosign
    env:
      - COSIGN_EXPERIMENTAL=1
    args:
      - sign
      - "--yes"
      - '${artifact}'
    artifacts: all
    output: true
