-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathTaskfile.yml
145 lines (129 loc) · 3.34 KB
/
Taskfile.yml
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
144
145
version: '3'
vars:
BINARY_NAME: bt-hid-relay
SERVICE_NAME: bt-hid-relay.service
INSTALL_PATH: /usr/local/bin
SERVICE_PATH: /etc/systemd/system
tasks:
default:
cmds:
- task: build
build:
desc: Build the application
cmds:
- echo "Building {{.BINARY_NAME}}..."
- go build -ldflags="-s -w" -o bin/{{.BINARY_NAME}} ./cmd/bt-hid-relay/
sources:
- ./**/*.go
generates:
- bin/{{.BINARY_NAME}}.release
vars:
BINARY_NAME: "{{.BINARY_NAME}}.release"
build-debug:
desc: Build with debug flags
cmds:
- echo "Building {{.BINARY_NAME}} with debug..."
- go build -tags debug -o bin/{{.BINARY_NAME}} ./cmd/bt-hid-relay/
sources:
- ./**/*.go
generates:
- bin/{{.BINARY_NAME}}.debug
vars:
BINARY_NAME: "{{.BINARY_NAME}}.debug"
clean:
desc: Clean build artifacts
cmds:
- echo "Cleaning..."
- rm -f bin/{{.BINARY_NAME}}.*
- echo "Done"
# verbose tests
test:
desc: Run tests
deps: [clean]
cmds:
- echo "Running tests..."
- go test ./...
run:
desc: Run the application locally
deps: [build-debug]
cmds:
- echo "Running {{.BINARY_NAME}}..."
- sudo ./bin/{{.BINARY_NAME}}.debug -debug
requires:
root: true
doctor:
desc: Run the diagnose tool
cmds:
- echo "Running diagnose tool..."
- go run ./cmd/diagnose-io/
requires:
root: true
simulate:
desc: Run the simulate tool
deps: [build-debug]
cmds:
- echo "Running simulate tool..."
- go run ./cmd/simulate-input/
requires:
root: true
update-dependencies:
desc: Update dependencies
cmds:
- go get -u ./...
- go mod tidy
service:install:
desc: Install the service
deps: [build]
cmds:
- echo "Installing {{.BINARY_NAME}} service..."
- systemctl stop {{.BINARY_NAME}}.service || true
- cp bin/{{.BINARY_NAME}}.release {{.INSTALL_PATH}}/{{.BINARY_NAME}}
- cp {{.SERVICE_NAME}} {{.SERVICE_PATH}}/
- systemctl daemon-reload
- systemctl enable {{.BINARY_NAME}}.service
- systemctl start {{.BINARY_NAME}}.service
requires:
root: true
service:uninstall:
desc: Uninstall the service
cmds:
- echo "Uninstalling {{.BINARY_NAME}} service..."
- systemctl stop {{.BINARY_NAME}}.service || true
- systemctl disable {{.BINARY_NAME}}.service || true
- rm -f {{.SERVICE_PATH}}/{{.SERVICE_NAME}}
- rm -f {{.INSTALL_PATH}}/{{.BINARY_NAME}}
- systemctl daemon-reload
- systemctl reset-failed {{.BINARY_NAME}}.service || true
requires:
root: true
service:status:
desc: Check service status
cmds:
- systemctl status {{.BINARY_NAME}}.service || true
requires:
root: true
service:logs:
desc: View service logs
cmds:
- journalctl -u {{.BINARY_NAME}}.service --follow
requires:
root: true
service:start:
desc: Start the service
deps: [build]
cmds:
- systemctl start {{.BINARY_NAME}}.service
requires:
root: true
service:stop:
desc: Stop the service
cmds:
- systemctl stop {{.BINARY_NAME}}.service
requires:
root: true
service:restart:
desc: Restart the service
cmds:
- systemctl restart {{.BINARY_NAME}}.service
requires:
root: true