# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

project_name: claude-mnemonic

before:
  hooks:
    - go mod tidy
    # Download ONNX runtime library (workflow-prepare.sh already handles CI, this is fallback for local builds)
    - bash ./scripts/download-onnx-libs.sh auto
    # Generate versioned package.json from template and build Vue dashboard
    - bash -c "sed 's/{{ .Version }}/{{ .Version }}/g' ui/package.json.tpl > ui/package.json"
    - bash -c "cd ui && npm ci --silent && npm run build"
    - bash -c "rm -rf internal/worker/static && mkdir -p internal/worker/static && cp -r ui/dist/* internal/worker/static/"
    # Generate plugin config files for archives (in .claude-plugin/)
    - bash scripts/generate-plugin-config.sh

builds:
  # Worker service
  - id: worker
    main: ./cmd/worker
    binary: worker
    env:
      - CGO_ENABLED=1
    tags:
      - fts5
    flags:
      - -trimpath
    ldflags:
      - -s -w
      - -X main.Version={{.Version}}
      - -X github.com/lukaszraczylo/claude-mnemonic/pkg/hooks.Version={{.Version}}
    goos:
      - darwin
      - linux
      - windows
    goarch:
      - amd64
      - arm64
    ignore:
      - goos: darwin
        goarch: amd64
      - goos: linux
        goarch: arm64
      - goos: windows
        goarch: arm64

  # MCP server
  - id: mcp-server
    main: ./cmd/mcp
    binary: mcp-server
    env:
      - CGO_ENABLED=1
    tags:
      - fts5
    flags:
      - -trimpath
    ldflags:
      - -s -w
      - -X main.Version={{.Version}}
      - -X github.com/lukaszraczylo/claude-mnemonic/pkg/hooks.Version={{.Version}}
    goos:
      - darwin
      - linux
      - windows
    goarch:
      - amd64
      - arm64
    ignore:
      - goos: darwin
        goarch: amd64
      - goos: linux
        goarch: arm64
      - goos: windows
        goarch: arm64

  # Hook: session-start
  - id: hook-session-start
    main: ./cmd/hooks/session-start
    binary: hooks/session-start
    env:
      - CGO_ENABLED=1
    tags:
      - fts5
    flags:
      - -trimpath
    ldflags:
      - -s -w
      - -X main.Version={{.Version}}
      - -X github.com/lukaszraczylo/claude-mnemonic/pkg/hooks.Version={{.Version}}
    goos:
      - darwin
      - linux
      - windows
    goarch:
      - amd64
      - arm64
    ignore:
      - goos: darwin
        goarch: amd64
      - goos: linux
        goarch: arm64
      - goos: windows
        goarch: arm64

  # Hook: user-prompt
  - id: hook-user-prompt
    main: ./cmd/hooks/user-prompt
    binary: hooks/user-prompt
    env:
      - CGO_ENABLED=1
    tags:
      - fts5
    flags:
      - -trimpath
    ldflags:
      - -s -w
      - -X main.Version={{.Version}}
      - -X github.com/lukaszraczylo/claude-mnemonic/pkg/hooks.Version={{.Version}}
    goos:
      - darwin
      - linux
      - windows
    goarch:
      - amd64
      - arm64
    ignore:
      - goos: darwin
        goarch: amd64
      - goos: linux
        goarch: arm64
      - goos: windows
        goarch: arm64

  # Hook: post-tool-use
  - id: hook-post-tool-use
    main: ./cmd/hooks/post-tool-use
    binary: hooks/post-tool-use
    env:
      - CGO_ENABLED=1
    tags:
      - fts5
    flags:
      - -trimpath
    ldflags:
      - -s -w
      - -X main.Version={{.Version}}
      - -X github.com/lukaszraczylo/claude-mnemonic/pkg/hooks.Version={{.Version}}
    goos:
      - darwin
      - linux
      - windows
    goarch:
      - amd64
      - arm64
    ignore:
      - goos: darwin
        goarch: amd64
      - goos: linux
        goarch: arm64
      - goos: windows
        goarch: arm64

  # Hook: subagent-stop
  - id: hook-subagent-stop
    main: ./cmd/hooks/subagent-stop
    binary: hooks/subagent-stop
    env:
      - CGO_ENABLED=1
    tags:
      - fts5
    flags:
      - -trimpath
    ldflags:
      - -s -w
      - -X main.Version={{.Version}}
      - -X github.com/lukaszraczylo/claude-mnemonic/pkg/hooks.Version={{.Version}}
    goos:
      - darwin
      - linux
      - windows
    goarch:
      - amd64
      - arm64
    ignore:
      - goos: darwin
        goarch: amd64
      - goos: linux
        goarch: arm64
      - goos: windows
        goarch: arm64

  # Hook: stop
  - id: hook-stop
    main: ./cmd/hooks/stop
    binary: hooks/stop
    env:
      - CGO_ENABLED=1
    tags:
      - fts5
    flags:
      - -trimpath
    ldflags:
      - -s -w
      - -X main.Version={{.Version}}
      - -X github.com/lukaszraczylo/claude-mnemonic/pkg/hooks.Version={{.Version}}
    goos:
      - darwin
      - linux
      - windows
    goarch:
      - amd64
      - arm64
    ignore:
      - goos: darwin
        goarch: amd64
      - goos: linux
        goarch: arm64
      - goos: windows
        goarch: arm64

  # Hook: statusline
  - id: hook-statusline
    main: ./cmd/hooks/statusline
    binary: hooks/statusline
    env:
      - CGO_ENABLED=1
    tags:
      - fts5
    flags:
      - -trimpath
    ldflags:
      - -s -w
      - -X main.Version={{.Version}}
      - -X github.com/lukaszraczylo/claude-mnemonic/pkg/hooks.Version={{.Version}}
    goos:
      - darwin
      - linux
      - windows
    goarch:
      - amd64
      - arm64
    ignore:
      - goos: darwin
        goarch: amd64
      - goos: linux
        goarch: arm64
      - goos: windows
        goarch: arm64

archives:
  - id: default
    formats:
      - tar.gz
    name_template: >-
      {{ .ProjectName }}_
      {{- .Version }}_
      {{- .Os }}_
      {{- .Arch }}
    files:
      - src: .claude-plugin/*
        dst: .claude-plugin
        strip_parent: true
      - src: plugin/hooks/hooks.json
        dst: hooks
        strip_parent: true
      - src: plugin/commands/*
        dst: commands
        strip_parent: true
    format_overrides:
      - goos: windows
        formats:
          - zip

checksum:
  name_template: 'checksums.txt'

changelog:
  sort: asc
  filters:
    exclude:
      - '^docs:'
      - '^test:'
      - '^chore:'
      - Merge pull request
      - Merge branch

release:
  github:
    owner: lukaszraczylo
    name: claude-mnemonic
  draft: false
  prerelease: auto
  name_template: "v{{.Version}}"
  header: |
    ## Claude Mnemonic v{{.Version}}

    Persistent memory system for Claude Code.

    ### Installation

    ```bash
    curl -sSL https://raw.githubusercontent.com/lukaszraczylo/claude-mnemonic/main/scripts/install.sh | bash
    ```

signs:
  - cmd: cosign
    signature: "${artifact}.sigstore.json"
    args:
      - sign-blob
      - "--bundle=${signature}"
      - "${artifact}"
      - "--yes"
    artifacts: checksum
    output: true
