# GoReleaser configuration for molecule-cli
# https://goreleaser.com/install/
#
# Used by .github/workflows/release.yml on tag push (refs/tags/v*).
# Produces multi-OS binaries (linux/darwin/windows × amd64/arm64),
# tar.gz/zip archives that include pre-generated shell completions,
# a sha256 checksums file, and a GitHub Release.
#
# Run locally:
#   goreleaser check    — validate the config
#   goreleaser release --snapshot --clean    — dry-run build (no upload)

version: 2

env:
  - GO111MODULE=on

before:
  hooks:
    - go mod tidy
    # Pre-generate shell completions so the archive ships them. Users
    # can drop completions/molecule.bash into ~/.bash_completion.d/, etc.
    # `molecule completion <shell>` also still works at runtime.
    - mkdir -p completions
    - sh -c 'go run ./cmd/molecule completion bash > completions/molecule.bash'
    - sh -c 'go run ./cmd/molecule completion zsh > completions/_molecule'
    - sh -c 'go run ./cmd/molecule completion fish > completions/molecule.fish'

builds:
  - id: molecule
    dir: .
    main: ./cmd/molecule
    binary: molecule
    goos:
      - linux
      - darwin
      - windows
    goarch:
      - amd64
      - arm64
    env:
      - CGO_ENABLED=0
    flags:
      - -trimpath

archives:
  - id: default
    formats: [tar.gz]
    format_overrides:
      - goos: windows
        formats: [zip]
    files:
      - src: completions/**/*
        dst: completions

snapshot:
  name_template: "{{.Tag}}-snapshot"

checksum:
  name_template: 'molecule_{{.Os}}_{{.Arch}}_{{.Version}}_checksums.txt'
  algorithm: sha256

release:
  github:
    owner: Molecule-AI
    name: molecule-cli
  draft: false
  name_template: "{{.Tag}}"

# Homebrew tap formula is managed by .github/workflows/release.yml
# (separate workflow step updates the formula on tag push).
# If GoReleaser takes over Homebrew later, add a brew section here.
