-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.yml
More file actions
91 lines (80 loc) · 3.91 KB
/
Taskfile.yml
File metadata and controls
91 lines (80 loc) · 3.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
version: '3'
tasks:
default:
desc: Show available tasks
cmds:
- task --list
build:
desc: Build the dcocheck binary
dir: dcocheck
cmds:
- go build -o ../bin/dcocheck ./cmd/dcocheck
test:
desc: Run all tests
dir: dcocheck
cmds:
- go test ./...
test-coverage:
desc: Run tests with coverage report
dir: dcocheck
cmds:
- go test -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out -o coverage.html
- go tool cover -func=coverage.out
lint:
desc: Run linter
dir: dcocheck
cmds:
- go vet ./...
tidy:
desc: Tidy go modules
dir: dcocheck
cmds:
- go mod tidy
clean:
desc: Clean build artifacts
cmds:
- rm -rf bin/ dist/ dcocheck/coverage.out dcocheck/coverage.html
build-release:
desc: "Build release binaries for all platforms, package as tarballs, and generate checksums. Requires VERSION variable. NOTE: Intended for CI/Linux environments (uses sha256sum)."
requires:
vars: [VERSION]
cmds:
- mkdir -p dist
- |
set -e
cd dcocheck
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.version={{.VERSION}}" -o ../dist/dcocheck ./cmd/dcocheck
(cd ../dist && tar -czf dcocheck-linux-amd64.tar.gz dcocheck && rm dcocheck)
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X main.version={{.VERSION}}" -o ../dist/dcocheck ./cmd/dcocheck
(cd ../dist && tar -czf dcocheck-linux-arm64.tar.gz dcocheck && rm dcocheck)
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X main.version={{.VERSION}}" -o ../dist/dcocheck ./cmd/dcocheck
(cd ../dist && tar -czf dcocheck-darwin-amd64.tar.gz dcocheck && rm dcocheck)
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.version={{.VERSION}}" -o ../dist/dcocheck ./cmd/dcocheck
(cd ../dist && tar -czf dcocheck-darwin-arm64.tar.gz dcocheck && rm dcocheck)
cd ../dist && sha256sum dcocheck-*.tar.gz > checksums.txt
update-formula:
desc: "Update Homebrew formula in the checked-out homebrew-tools tap. Requires VERSION and TAG variables. NOTE: Intended for CI/Linux environments (uses sha256sum and sed -i). Expects homebrew-tools/ to be checked out in the working directory."
requires:
vars: [VERSION, TAG]
cmds:
- |
set -e
DARWIN_AMD64_SHA=$(sha256sum dist/dcocheck-darwin-amd64.tar.gz | awk '{print $1}')
DARWIN_ARM64_SHA=$(sha256sum dist/dcocheck-darwin-arm64.tar.gz | awk '{print $1}')
LINUX_AMD64_SHA=$(sha256sum dist/dcocheck-linux-amd64.tar.gz | awk '{print $1}')
LINUX_ARM64_SHA=$(sha256sum dist/dcocheck-linux-arm64.tar.gz | awk '{print $1}')
cp Formula/dcocheck.rb homebrew-tools/Formula/dcocheck.rb
sed -i "s/version \"[^\"]*\"/version \"{{.VERSION}}\"/" homebrew-tools/Formula/dcocheck.rb
sed -i "s/sha256 \"[^\"]*\" # darwin-arm64/sha256 \"${DARWIN_ARM64_SHA}\" # darwin-arm64/" homebrew-tools/Formula/dcocheck.rb
sed -i "s/sha256 \"[^\"]*\" # darwin-amd64/sha256 \"${DARWIN_AMD64_SHA}\" # darwin-amd64/" homebrew-tools/Formula/dcocheck.rb
sed -i "s/sha256 \"[^\"]*\" # linux-arm64/sha256 \"${LINUX_ARM64_SHA}\" # linux-arm64/" homebrew-tools/Formula/dcocheck.rb
sed -i "s/sha256 \"[^\"]*\" # linux-amd64/sha256 \"${LINUX_AMD64_SHA}\" # linux-amd64/" homebrew-tools/Formula/dcocheck.rb
build-all:
desc: Build for all platforms (development build, no version injection)
dir: dcocheck
cmds:
- GOOS=linux GOARCH=amd64 go build -o ../dist/dcocheck-linux-amd64 ./cmd/dcocheck
- GOOS=linux GOARCH=arm64 go build -o ../dist/dcocheck-linux-arm64 ./cmd/dcocheck
- GOOS=darwin GOARCH=amd64 go build -o ../dist/dcocheck-darwin-amd64 ./cmd/dcocheck
- GOOS=darwin GOARCH=arm64 go build -o ../dist/dcocheck-darwin-arm64 ./cmd/dcocheck