project_name: glab

release:
  prerelease: auto
  extra_files:
    - glob: "./bin/*.exe"

before:
  hooks:
    - go mod tidy
    - make manpage

builds:
  - <<: &build_defaults
      main: ./cmd/glab
      binary: bin/glab
      env:
        - CGO_ENABLED=0
      ldflags:
        - -s -w -X main.version=v{{.Version}} -X main.build={{time "2006-01-02"}}
    id: macos
    goos: [darwin]
    goarch: [amd64, arm64]

  - <<: *build_defaults
    id: linux
    goos: [linux]
    goarch: ["386", arm, amd64, arm64]

  - <<: *build_defaults
    id: windows
    goos: [windows]
    goarch: ["386", amd64]

dockers:
  - image_templates:
      - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-amd64"
      - "gitlab/glab:{{ .Tag }}-amd64"
    dockerfile: Dockerfile
    use: buildx
    build_flag_templates:
      - "--pull"
      - "--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"
    extra_files:
      - scripts/entrypoint.sh
  - image_templates:
      - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-arm64"
      - "gitlab/glab:{{ .Tag }}-arm64"
    dockerfile: Dockerfile
    use: buildx
    build_flag_templates:
      - "--pull"
      - "--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"
    goarch: arm64
    extra_files:
      - scripts/entrypoint.sh
docker_manifests:
  - name_template: "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}"
    image_templates:
      - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-amd64"
      - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-arm64"
  - name_template: "registry.gitlab.com/gitlab-org/cli:latest"
    image_templates:
      - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-amd64"
      - "registry.gitlab.com/gitlab-org/cli:{{ .Tag }}-arm64"
  - name_template: "gitlab/glab:{{ .Tag }}"
    image_templates:
      - "gitlab/glab:{{ .Tag }}-amd64"
      - "gitlab/glab:{{ .Tag }}-arm64"
  - name_template: "gitlab/glab:latest"
    image_templates:
      - "gitlab/glab:{{ .Tag }}-amd64"
      - "gitlab/glab:{{ .Tag }}-arm64"
archives:
  - id: nix
    builds: [macos, linux]
    <<: &archive_defaults
      name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
      wrap_in_directory: false
    format: tar.gz
    replacements:
      darwin: macOS
      linux: Linux
      <<: &arch_replacemens
        386: i386
        amd64: x86_64

  - id: windows
    builds: [windows]
    <<: *archive_defaults
    format: zip
    replacements:
      windows: Windows
      <<: *arch_replacemens

nfpms:
  - id: foo
    package_name: glab
    file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"

    # Build IDs for the builds you want to create NFPM packages for.
    # Defaults to all builds.

    replacements:
      amd64: x86_64
      386: i386
      darwin: macOS
      linux: Linux
    vendor: GitLab
    homepage: https://gitlab.com/gitlab-org/cli
    # using service-desk email https://docs.gitlab.com/ee/user/project/service_desk.html
    maintainer: GitLab<contact-project+gitlab-org-cli-34675721-issue-@incoming.gitlab.com>
    description: An open source GitLab CLI tool
    license: MIT
    formats:
      - apk
      - deb
      - rpm
    dependencies:
      - git
    bindir: /usr
    contents:
      - src: "./share/man/man1/glab*.1"
        dst: "/usr/share/man/man1"

checksum:
  name_template: "checksums.txt"
snapshot:
  name_template: "{{ .Tag }}"
changelog:
  sort: asc
  filters:
    exclude:
      - >
        ^docs(\(.*\))*:
      - >
        ^test(\(.*\))*:
      - "^Merge branch"
      - "^chore"
      - "^Update README.md"
