project_name: eaglecast

env:
  - GO111MODULE=on
  - CGO_ENABLED=0
  - GITHUB_ORG=h202-wq

before:
  hooks:
    - make build-frontend

builds:
  - binary: eaglecast
    main: ./cmd
    goos:
      - linux
      - windows
      - darwin
      - freebsd
      - openbsd
      - netbsd
    goarch:
      - amd64
      - arm64
      - arm
    goarm:
      - 6
      - 7
    ignore:
      - goos: windows
        goarch: arm
    ldflags:
      - -s -w -X "main.buildString={{ .Tag }} ({{ .ShortCommit }} {{ .Date }}, {{ .Os }}/{{ .Arch }})" -X "main.versionString={{ .Tag }}"

    hooks:
      # stuff executables with static assets.
      post: make pack-bin BIN={{ .Path }}

archives:
  - format: tar.gz
    files:
      - README.md
      - LICENSE

dockers:
  - use: buildx
    goos: linux
    goarch: amd64
    ids:
      - eaglecast
    image_templates:
      - "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:latest-amd64"
      - "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Tag }}-amd64"
    build_flag_templates:
      - --platform=linux/amd64
      - --label=org.opencontainers.image.title={{ .ProjectName }}
      - --label=org.opencontainers.image.description={{ .ProjectName }}
      - --label=org.opencontainers.image.url=https://source.offmarket.win/aleagle/EagleCast
      - --label=org.opencontainers.image.source=https://source.offmarket.win/aleagle/EagleCast
      - --label=org.opencontainers.image.version={{ .Version }}
      - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
      - --label=org.opencontainers.image.revision={{ .FullCommit }}
      - --label=org.opencontainers.image.licenses=AGPL-3.0
    dockerfile: Dockerfile.goreleaser
    extra_files:
      - config.toml.sample
      - docker-entrypoint.sh
  - use: buildx
    goos: linux
    goarch: arm64
    ids:
      - eaglecast
    image_templates:
      - "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:latest-arm64v8"
      - "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
    build_flag_templates:
      - --platform=linux/arm64/v8
      - --label=org.opencontainers.image.title={{ .ProjectName }}
      - --label=org.opencontainers.image.description={{ .ProjectName }}
      - --label=org.opencontainers.image.url=https://source.offmarket.win/aleagle/EagleCast
      - --label=org.opencontainers.image.source=https://source.offmarket.win/aleagle/EagleCast
      - --label=org.opencontainers.image.version={{ .Version }}
      - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
      - --label=org.opencontainers.image.revision={{ .FullCommit }}
      - --label=org.opencontainers.image.licenses=AGPL-3.0
    dockerfile: Dockerfile.goreleaser
    extra_files:
      - config.toml.sample
      - docker-entrypoint.sh
  - use: buildx
    goos: linux
    goarch: arm
    goarm: 6
    ids:
      - eaglecast
    image_templates:
      - "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:latest-armv6"
      - "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Tag }}-armv6"
    build_flag_templates:
      - --platform=linux/arm/v6
      - --label=org.opencontainers.image.title={{ .ProjectName }}
      - --label=org.opencontainers.image.description={{ .ProjectName }}
      - --label=org.opencontainers.image.url=https://source.offmarket.win/aleagle/EagleCast
      - --label=org.opencontainers.image.source=https://source.offmarket.win/aleagle/EagleCast
      - --label=org.opencontainers.image.version={{ .Version }}
      - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
      - --label=org.opencontainers.image.revision={{ .FullCommit }}
      - --label=org.opencontainers.image.licenses=AGPL-3.0
    dockerfile: Dockerfile.goreleaser
    extra_files:
      - config.toml.sample
      - docker-entrypoint.sh
  - use: buildx
    goos: linux
    goarch: arm
    goarm: 7
    ids:
      - eaglecast
    image_templates:
      - "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:latest-armv7"
      - "ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Tag }}-armv7"
    build_flag_templates:
      - --platform=linux/arm/v7
      - --label=org.opencontainers.image.title={{ .ProjectName }}
      - --label=org.opencontainers.image.description={{ .ProjectName }}
      - --label=org.opencontainers.image.url=https://source.offmarket.win/aleagle/EagleCast
      - --label=org.opencontainers.image.source=https://source.offmarket.win/aleagle/EagleCast
      - --label=org.opencontainers.image.version={{ .Version }}
      - --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
      - --label=org.opencontainers.image.revision={{ .FullCommit }}
      - --label=org.opencontainers.image.licenses=AGPL-3.0
    dockerfile: Dockerfile.goreleaser
    extra_files:
      - config.toml.sample
      - docker-entrypoint.sh

docker_manifests:
  - name_template: ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:latest
    image_templates:
      - ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:latest-amd64
      - ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:latest-arm64v8
      - ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:latest-armv6
      - ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:latest-armv7
  - name_template: ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Tag }}
    image_templates:
      - ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Tag }}-amd64
      - ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Tag }}-arm64v8
      - ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Tag }}-armv6
      - ghcr.io/{{ .Env.GITHUB_ORG }}/{{ .ProjectName }}:{{ .Tag }}-armv7
