# GoReleaser config for bookmarks.
# Triggered by tags shaped like `bookmarks/vX.Y.Z`.
version: 2

project_name: bookmarks

before:
  hooks:
    - go mod tidy

builds:
  - id: bookmarks
    main: .
    binary: bookmarks
    env:
      - CGO_ENABLED=0
    goos:
      - linux
      - darwin
      - windows
    goarch:
      - amd64
      - arm64
    ignore:
      - goos: windows
        goarch: arm64
    ldflags:
      - -s -w
      - -X main.version={{.Version}}
      - -X main.commit={{.Commit}}
      - -X main.date={{.Date}}

archives:
  - id: bookmarks
    name_template: >-
      {{ .ProjectName }}_{{ .Version }}_
      {{- if eq .Os "darwin" }}macos{{- else }}{{ .Os }}{{ end }}_
      {{- if eq .Arch "amd64" }}x86_64{{- else }}{{ .Arch }}{{ end }}
    formats: [tar.gz]
    format_overrides:
      - goos: windows
        formats: [zip]
    files:
      - README.md

checksum:
  name_template: "checksums.txt"

snapshot:
  version_template: "0.0.0-snapshot-{{.ShortCommit}}"

changelog:
  # Disabled: the workflow's `gh release create --generate-notes` produces the
  # real notes on the prefixed `<app>/vX.Y.Z` tag. GoReleaser's GitHub compare
  # API uses the stripped version (e.g. v0.4.0), which 404s since the real tag
  # is prefixed (e.g. posts/v0.4.0).
  disable: true

release:
  # Disabled: workflow uploads artifacts to the real `bookmarks/vX.Y.Z` git tag
  # using `gh release create`. GoReleaser OSS can't natively map a stripped
  # version back to a prefixed tag without the Pro `monorepo` feature.
  disable: true

brews:
  - name: bookmarks
    repository:
      owner: stevedylandev
      name: homebrew-tap
      token: "{{ .Env.HOMEBREW_TAP_TOKEN }}"
    url_template: "https://github.com/stevedylandev/andromeda/releases/download/bookmarks/v{{ .Version }}/{{ .ArtifactName }}"
    homepage: "https://github.com/stevedylandev/andromeda"
    description: "Self-hosted link saver with categories and JSON API"
    license: "MIT"
    commit_author:
      name: goreleaserbot
      email: bot@goreleaser.com
    commit_msg_template: "brew: bookmarks {{ .Tag }}"
    directory: Formula
    install: |
      bin.install "bookmarks"
