Skip to content

Commit

Permalink
Add Taskfile
Browse files Browse the repository at this point in the history
  • Loading branch information
dkorunic committed Jul 25, 2024
1 parent b5d49b2 commit c1649b7
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
version: "3"

vars:
TARGET: dnstrace
GIT_LAST_TAG:
sh: git describe --abbrev=0 --tags 2>/dev/null || echo latest
GIT_HEAD_COMMIT:
sh: git rev-parse --short HEAD 2>/dev/null || echo unknown
GIT_TAG_COMMIT:
sh: git rev-parse --short {{.GIT_LAST_TAG}} 2>/dev/null || echo unknown
GIT_MODIFIED1:
sh: git diff {{.GIT_HEAD_COMMIT}} {{.GIT_TAG_COMMIT}} --quiet 2>/dev/null || echo .dev
GIT_MODIFIED2:
sh: git diff --quiet 2>/dev/null || echo .dirty
GIT_MODIFIED:
sh: echo "{{.GIT_MODIFIED1}}{{.GIT_MODIFIED2}}"
BUILD_DATE:
sh: date -u '+%Y-%m-%dT%H:%M:%SZ'

env:
CGO_ENABLED: 1

tasks:
default:
cmds:
- task: update
- task: build

update:
cmds:
- go get -u
- go mod tidy

check:
cmds:
- gomajor list

fmt:
cmds:
- go mod tidy
- gci write .
- gofumpt -l -w .
- betteralign -apply ./...

build:
cmds:
- task: fmt
- go build -trimpath -pgo=auto -ldflags="-s -w -X main.GitTag={{.GIT_LAST_TAG}} -X main.GitCommit={{.GIT_HEAD_COMMIT}} -X main.GitDirty={{.GIT_MODIFIED}} -X main.BuildTime={{.BUILD_DATE}}" -o {{.TARGET}}

build-debug:
env:
CGO_ENABLED: 1
cmds:
- task: update
- task: fmt
- go build -ldflags="-X main.GitTag={{.GIT_LAST_TAG}} -X main.GitCommit={{.GIT_HEAD_COMMIT}} -X main.GitDirty={{.GIT_MODIFIED}} -X main.BuildTime={{.BUILD_DATE}}" -race -o {{.TARGET}}

lint:
cmds:
- task: fmt
- golangci-lint run --timeout 5m

release:
cmds:
- goreleaser release --clean -p 4

0 comments on commit c1649b7

Please sign in to comment.