before:
  hooks:
    - go mod download

changelog:
  sort: desc
  use: github
  filters:
    exclude:
    - Merge branch
    - Merge pull request

builds:
  - env:
      - CGO_ENABLED=0
    goos:
      - linux
      - windows
      - darwin
    goarch:
      - 386
      - amd64
      - arm
      - arm64
    goarm:
      # Because of a limitation in DEB packaging we can only build and package
      # a single ARMv6 or v7 variant at a single time. As ARMv6 is upwards
      # compatible with ARMv7 so let's only build ARMv6 here (default value
      # anyway)
      - 6
    ignore:
      - goos: windows
        goarch: arm
      - goos: windows
        goarch: arm64
      - goos: darwin
        goarch: 386
      - goos: darwin
        goarch: arm
    main: ./
    binary: symfony
    ldflags: -s -w -X 'main.channel={{ if index .Env "AUTOUPDATE_CHANNEL" }}{{ .Env.AUTOUPDATE_CHANNEL }}{{ else }}dev{{ end }}' -X 'main.buildDate={{ .Date }}' -X 'main.version={{ .Version }}'
    flags:
      - -trimpath

archives:
  - name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}'
    format_overrides:
    - goos: windows
      format: zip
    files:
      - README.md
      - LICENSE

checksum:
  name_template: 'checksums.txt'

# create a source tarball
# https://goreleaser.com/customization/source/
source:
  enabled: true

snapshot:
  name_template: "next"

universal_binaries:
  - replace: true
    name_template: symfony

# sign all artifacts
# https://goreleaser.com/customization/sign
signs:
- cmd: cosign
  certificate: '${artifact}.pem'
  args:
    - sign-blob
    - '--output-certificate=${certificate}'
    - '--output-signature=${signature}'
    - '${artifact}'
    - "--yes"
  artifacts: all
  output: true

release:
  footer: |
    **Full Changelog**: https://github.com/symfony-cli/symfony-cli/compare/{{ .PreviousTag }}...{{ .Tag }}

brews:
  - repository:
      owner: symfony-cli
      name: homebrew-tap
      token: "{{ .Env.TAP_GITHUB_TOKEN }}"
    commit_author:
      name: Fabien Potencier
      email: fabien@symfony.com
    folder: Formula
    # Homebrew supports only a single GOARM variant and ARMv6 is upwards
    # compatible with ARMv7 so let's keep ARMv6 here (default value anyway)
    goarm: "6"
    homepage: https://symfony.com
    description: Symfony CLI helps Symfony developers manage projects, from local code to remote infrastructure
    license: AGPL-3.0
    test: |
      system "#{bin}/symfony version"
    dependencies:
    - name: git
      type: optional
    install: |-
      bin.install "symfony"
    service: |-
      run ["#{bin}/symfony", "local:proxy:start", "--foreground"]
      keep_alive true

nfpms:
  - file_name_template: '{{ .ConventionalFileName }}'
    id: packages
    homepage: https://symfony.com
    description: Symfony CLI helps Symfony developers manage projects, from local code to remote infrastructure
    maintainer: Fabien Potencier <fabien@symfony.com>
    license: AGPL-3.0
    vendor: Symfony
    formats:
    - apk
    - deb
    - rpm
    recommends:
    - git

dockers:
  - image_templates: [ "ghcr.io/symfony-cli/{{ .ProjectName }}:{{ .Version }}-amd64" ]
    goarch: amd64
    use: buildx
    build_flag_templates:
      - "--pull"
      - "--platform=linux/amd64"
      - "--label=org.opencontainers.image.source=https://github.com/symfony-cli/symfony-cli"
      - "--label=org.opencontainers.image.created={{.Date}}"
      - "--label=org.opencontainers.image.version={{.Version}}"
  - image_templates: [ "ghcr.io/symfony-cli/{{ .ProjectName }}:{{ .Version }}-arm64" ]
    goarch: arm64
    use: buildx
    build_flag_templates:
      - "--pull"
      - "--platform=linux/arm64"
      - "--label=org.opencontainers.image.source=https://github.com/symfony-cli/symfony-cli"
      - "--label=org.opencontainers.image.created={{.Date}}"
      - "--label=org.opencontainers.image.version={{.Version}}"
  - image_templates: [ "ghcr.io/symfony-cli/{{ .ProjectName }}:{{ .Version }}-arm32v6" ]
    goarch: arm
    goarm: '6'
    use: buildx
    build_flag_templates:
      - "--pull"
      - "--platform=linux/arm/v6"
      - "--label=org.opencontainers.image.source=https://github.com/symfony-cli/symfony-cli"
      - "--label=org.opencontainers.image.created={{.Date}}"
      - "--label=org.opencontainers.image.version={{.Version}}"
  - image_templates: [ "ghcr.io/symfony-cli/{{ .ProjectName }}:{{ .Version }}-arm32v7" ]
    goarch: arm
    # ARMv6 is upwards compatible with ARMv7
    goarm: '6'
    use: buildx
    build_flag_templates:
      - "--pull"
      - "--platform=linux/arm/v7"
      - "--label=org.opencontainers.image.source=https://github.com/symfony-cli/symfony-cli"
      - "--label=org.opencontainers.image.created={{.Date}}"
      - "--label=org.opencontainers.image.version={{.Version}}"

docker_manifests:
  - name_template: ghcr.io/symfony-cli/{{ .ProjectName }}:{{ .Version }}
    image_templates: &docker_images
      - ghcr.io/symfony-cli/{{ .ProjectName }}:{{ .Version }}-amd64
      - ghcr.io/symfony-cli/{{ .ProjectName }}:{{ .Version }}-arm64
      - ghcr.io/symfony-cli/{{ .ProjectName }}:{{ .Version }}-arm32v6
      - ghcr.io/symfony-cli/{{ .ProjectName }}:{{ .Version }}-arm32v7
  - name_template: ghcr.io/symfony-cli/{{ .ProjectName }}:v{{ .Major }}
    image_templates: *docker_images
  - name_template: ghcr.io/symfony-cli/{{ .ProjectName }}:v{{ .Major }}.{{ .Minor }}
    image_templates: *docker_images
  - name_template: ghcr.io/symfony-cli/{{ .ProjectName }}:latest
    image_templates: *docker_images
