# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
  hooks:
    # You may remove this if you don't use go modules.
    - go mod tidy
    # you may remove this if you don't need go generate
    - go generate ./...
    - go run download-geofabrik.go generate
    - go run download-geofabrik.go --service="openstreetmap.fr" generate
    - go run download-geofabrik.go --service="bbbike" generate
    - go run download-geofabrik.go --service="osmtoday" generate
    - cat .README.md1 > README.md
    - go run download-geofabrik.go --help-long >> README.md
    - cat .README.md2 >> README.md
    - go run download-geofabrik.go list --markdown >> README.md
    - echo "" >> README.md
    - echo "## List of elements from openstreetmap.fr" >> README.md
    - go run download-geofabrik.go --service "openstreetmap.fr" list --markdown >> README.md
    - echo "" >> README.md
    - echo "## List of elements from bbbike.org" >> README.md
    - go run download-geofabrik.go --service "bbbike" list --markdown >> README.md
    - echo "" >> README.md
    - echo "## List of elements from osmtoday" >> README.md
    - go run download-geofabrik.go --service "osmtoday" list --markdown >> README.md


builds:
  - env:
      - CGO_ENABLED=0
    goos:
      - linux
      - windows
      - darwin
      - dragonfly
      - freebsd
      - illumos
      - netbsd
      - openbsd
      - solaris

    goarch:
      - amd64
      - 386
      - arm
      - arm64
      - mips
      - mips64
      - mips64le
      - mipsle
      - ppc64
      - ppc64le
      - s390x

    #goamd64:
    #  - v1
    #  - v2
    #  - v3
    #  - v4

    goarm:
      - 5
      - 6
      - 7

    ignore:
      - goos: darwin
        goarch: 386

    ldflags: >-
      -s -w
      -X main.version={{ .Version }}

universal_binaries:
  - replace: true

upx:
  - # Whether to enable it or not.
    #
    # Templates: allowed.
    enabled: false # remove upx since I've issues with it

    goos:
      - linux
      - windows

    # Compress argument.
    # Valid options are from '1' (faster) to '9' (better), and 'best'.
    compress: best

    # Whether to try LZMA (slower).
    lzma: true

    # Whether to try all methods and filters (slow).
    brute: true      

archives:
  - format: tar.gz
    # this name template makes the OS and Arch compatible with the results of `uname`.
    name_template: >-
      {{ .ProjectName }}_
      {{- title .Os }}_
      {{- if eq .Arch "amd64" }}x86_64
      {{- else if eq .Arch "386" }}i386
      {{- else }}{{ .Arch }}{{ end }}
      {{- if .Arm }}v{{ .Arm }}{{ end }}
    # use zip for windows archives
    format_overrides:
      - goos: windows
        format: zip
    files:
      - license*
      - LICENSE*
      - README.md
      - changelog*
      - CHANGELOG*
      - bbbike.yml
      - geofabrik.yml
      - openstreetmap.fr.yml
      - osmtoday.yml
checksum:
  name_template: 'checksums.txt'
snapshot:
  version_template: "{{ .Tag }}-next"

changelog:
  sort: asc
  filters:
    exclude:
      - "^docs:"
      - "^test:"

dockers:
  - goos: linux
    goarch: amd64
    #binaries:
    #  - download-geofabrik
    image_templates:
      - "juliennoblet/{{.ProjectName}}:latest"
      - "juliennoblet/{{.ProjectName}}:{{ .Tag }}"
      - "juliennoblet/{{.ProjectName}}:v{{ .Major }}"
      - "juliennoblet/{{.ProjectName}}:v{{ .Major }}.{{ .Minor }}"
    skip_push: auto
    dockerfile: Dockerfile
    extra_files:
      - geofabrik.yml
      - openstreetmap.fr.yml
      - bbbike.yml
      - osmtoday.yml