[tools]
"ubi:goreleaser/goreleaser" = "2.13.3"

[tasks.format]
description = "Format code"
run = """
go mod tidy
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix -test ./...
go fmt ./...
"""

[tasks.build]
description = "Build the Go project"
run = """
VERSION="${VERSION:-dev}"
COMMIT=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
go build -ldflags "-X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" -o bin/mh .
"""

[tasks.run]
description = "Build the Go project"
depends = ["build"]
run = """
./bin/mh -c config.example.json
"""

[tasks.test]
description = "run tests"
run = """
go test ./... -coverprofile=coverage.out
"""

[tasks.release-snapshot]
description = "Build snapshot release locally"
run = """
goreleaser build --snapshot --clean
"""

[tasks.release-check]
description = "Check goreleaser config"
run = """
goreleaser check
"""
