# https://taskfile.dev version: "3" vars: BIN_DIR: ./bin GOLANGCI_LINT_VERSION: v2.7.2 GOLANGCI: "{{.BIN_DIR}}/golangci-lint-{{.GOLANGCI_LINT_VERSION}}" tasks: ftl: desc: Run fmt, tidy, and lint. cmds: - task: fmt - task: tidy - task: lint fmt: desc: Run linters deps: - install-golangci-lint cmds: - "{{.GOLANGCI}} fmt" tidy: desc: Run go mod tidy. cmds: - go mod tidy {{.CLI_ARGS}} lint: desc: Run linters deps: - install-golangci-lint cmds: - "{{.GOLANGCI}} run" test: desc: Run Go tests. cmds: - go test ./... {{.CLI_ARGS}} create-bin-dir: desc: Create bin directory. cmds: - mkdir -p {{.BIN_DIR}} build: desc: Build the application. deps: - create-bin-dir vars: OUTPUT: '{{.OUTPUT | default (printf "%s/sarin" .BIN_DIR)}}' cmds: - rm -f {{.OUTPUT}} - >- CGO_ENABLED=0 GOEXPERIMENT=greenteagc go build -ldflags "-X 'go.aykhans.me/sarin/internal/version.Version=$(git describe --tags --always)' -X 'go.aykhans.me/sarin/internal/version.GitCommit=$(git rev-parse HEAD)' -X 'go.aykhans.me/sarin/internal/version.BuildDate=$(date -u +%Y-%m-%dT%H:%M:%SZ)' -X 'go.aykhans.me/sarin/internal/version.GoVersion=$(go version)' -s -w" -o {{.OUTPUT}} ./cmd/cli/main.go install-golangci-lint: desc: Install golangci-lint deps: - create-bin-dir status: - test -f {{.GOLANGCI}} cmds: - rm -f {{.GOLANGCI}} - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b {{.BIN_DIR}} {{.GOLANGCI_LINT_VERSION}} - mv {{.BIN_DIR}}/golangci-lint {{.GOLANGCI}}