# SPDX-FileCopyrightText: Amolith <amolith@secluded.site>
#
# SPDX-License-Identifier: CC0-1.0

[env]
CGO_ENABLED = "0"

[tools]
go = "latest"
"go:golang.org/x/vuln/cmd/govulncheck" = "latest"
"go:mvdan.cc/gofumpt" = "latest"
golangci-lint = "latest"

[tasks.build]
run = "go build -ldflags \"-X git.secluded.site/sb-mcp/internal/server.Version=$(git describe --tags --always --dirty 2>/dev/null || echo dev)\" ./cmd/sb-mcp/"

[tasks.install]
run = "go install -ldflags \"-X git.secluded.site/sb-mcp/internal/server.Version=$(git describe --tags --always --dirty 2>/dev/null || echo dev)\" ./cmd/sb-mcp/"

[tasks.test]
run = "go test -v ./..."

[tasks.fmt]
run = "gofumpt -w ."

[tasks.fix]
run = "jj --config 'fix.tools.gofumpt.command=[\"gofumpt\"]' --config 'fix.tools.gofumpt.patterns=[\"glob:**/*.go\"]' fix"

[tasks.lint]
run = "golangci-lint run"

[tasks.vuln]
run = "govulncheck ./..."

[tasks.vet]
run = "go vet ./..."

[tasks."test:quiet"]
run = """
output=$(go test ./... 2>&1)
if [ $? -eq 0 ]; then
  echo "✓"
else
  echo "$output"
  exit 1
fi
"""

[tasks.check]
depends = ["fmt", "vet", "lint", "vuln", "build", "test:quiet"]

[tasks.release]
description = "Interactive release workflow (tag, build, pack, upload)"
run = "fish release.fish"
