-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
143 lines (124 loc) · 3.55 KB
/
Taskfile.yml
File metadata and controls
143 lines (124 loc) · 3.55 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
version: "3"
vars:
BINARY_NAME: mkcd
MAIN_FILE: main.go
BUILD_DIR: dist
tasks:
default:
desc: Show available tasks
cmds:
- task --list
build:
desc: Build the binary using goreleaser (snapshot)
cmds:
- goreleaser build --snapshot --single-target
- |
# Copy the binary to root for the current platform
if [ "$(go env GOOS)" = "windows" ]; then
BINARY_PATH="$(find dist -name '{{.BINARY_NAME}}.exe' -type f | head -1)"
if [ -n "$BINARY_PATH" ]; then
cp "$BINARY_PATH" ./{{.BINARY_NAME}}.exe
fi
else
BINARY_PATH="$(find dist -name '{{.BINARY_NAME}}' -type f | head -1)"
if [ -n "$BINARY_PATH" ]; then
cp "$BINARY_PATH" ./{{.BINARY_NAME}}
chmod +x ./{{.BINARY_NAME}}
fi
fi
build-release:
desc: Build optimized binary for release using goreleaser
cmds:
- task: build
run:
desc: Build and run the tool
deps: [build]
cmds:
- ./{{.BINARY_NAME}}
install:
desc: Install the binary to $GOPATH/bin or $GOBIN
cmds:
- go install -ldflags="-s -w" -trimpath
install:system:
desc: Build for macOS using goreleaser and install to /usr/local/bin
cmds:
- goreleaser build --clean --snapshot --single-target --skip validate
- |
# Find the macOS binary and install it
BINARY_PATH="$(find dist -name '{{.BINARY_NAME}}' -type f | head -1)"
if [ -z "$BINARY_PATH" ]; then
echo "Error: Binary not found in dist directory"
exit 1
fi
echo "Installing {{.BINARY_NAME}} to /usr/local/bin..."
sudo cp "$BINARY_PATH" /usr/local/bin/{{.BINARY_NAME}}
sudo chmod +x /usr/local/bin/{{.BINARY_NAME}}
echo "{{.BINARY_NAME}} installed successfully!"
test:
desc: Run tests
cmds:
- go test -v ./...
test-coverage:
desc: Run tests with coverage
cmds:
- go test -v -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out -o coverage.html
fmt:
desc: Format Go code
cmds:
- go fmt ./...
vet:
desc: Run go vet
cmds:
- go vet ./...
lint:
desc: Run linters (fmt, vet)
cmds:
- task: fmt
- task: vet
clean:
desc: Clean build artifacts
cmds:
- rm -f {{.BINARY_NAME}} {{.BINARY_NAME}}.exe
- rm -rf {{.BUILD_DIR}}
- rm -f coverage.out coverage.html
check:
desc: Run all checks (fmt, vet, test)
cmds:
- task: fmt
- task: vet
- task: test
cross-build:
desc: Cross-compile for multiple platforms using goreleaser
cmds:
- goreleaser build --snapshot
release:build:
desc: Build release binaries locally using goreleaser (snapshot)
cmds:
- rm -rf {{.BUILD_DIR}}
- goreleaser build --snapshot
release:snapshot:
desc: Create a snapshot release locally (no git push)
cmds:
- rm -rf {{.BUILD_DIR}}
- goreleaser release --snapshot --clean
release:
desc: Create a full release (requires GITHUB_TOKEN and git tag)
env:
GITHUB_TOKEN: '{{env "GITHUB_TOKEN"}}'
cmds:
- |
if [ -z "${GITHUB_TOKEN}" ]; then
echo "Error: GITHUB_TOKEN environment variable is required"
echo "Please run: export GITHUB_TOKEN=your_token"
echo "Then run: task release"
exit 1
fi
echo "✓ Found GITHUB_TOKEN"
goreleaser release --clean
version:
desc: Show Go version and module info
cmds:
- go version
- go env GOMOD
- go list -m