-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
148 lines (120 loc) · 4.34 KB
/
Makefile
File metadata and controls
148 lines (120 loc) · 4.34 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
144
145
146
147
148
.PHONY: build build-no-restart build-ty build-taskd restart-daemon build-linux \
install clean test vet vuln audit coverage run daemon \
deploy deploy-service deploy-full status logs connect tag fmt lint
# Configuration
SERVER ?= root@cloud-claude
REMOTE_USER ?= runner
REMOTE_DIR ?= /home/runner
# Allow overriding the Go binary/toolchain (e.g. GO=go1.24.4 or mise exec -- go)
GO ?= go
# Version from git tag (e.g. v0.2.3 → 0.2.3), falls back to "dev"
VERSION ?= $(shell git describe --tags --always 2>/dev/null | sed 's/^v//' || echo dev)
LDFLAGS := -s -w -X main.version=$(VERSION)
# Build all binaries and (optionally) restart daemon if running
build: build-ty build-taskd restart-daemon
# Build binaries without touching any running daemon
build-no-restart: build-ty build-taskd
build-ty:
$(GO) build -ldflags="$(LDFLAGS)" -o bin/ty ./cmd/task
ln -sf ty bin/taskyou
build-taskd:
$(GO) build -ldflags="$(LDFLAGS)" -o bin/taskd ./cmd/taskd
# Restart daemon if it's running (silent if not). Never fail the build if we lack permissions.
restart-daemon:
@if pgrep -f "ty daemon" > /dev/null; then \
echo "Restarting daemon..."; \
pkill -f "ty daemon" || true; \
sleep 1; \
bin/ty daemon > /tmp/ty-daemon.log 2>&1 & \
sleep 1; \
echo "Daemon restarted (PID $$(pgrep -f 'ty daemon' || true))"; \
fi
# Build for Linux (server deployment)
build-linux:
GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o bin/taskd-linux ./cmd/taskd
# Install to GOBIN (usually ~/go/bin) - installs as 'ty', 'taskyou' (symlink), and 'taskd'
install:
go build -ldflags="$(LDFLAGS)" -o $(shell go env GOBIN)/ty ./cmd/task
ln -sf ty $(shell go env GOBIN)/taskyou
go build -ldflags="$(LDFLAGS)" -o $(shell go env GOBIN)/taskd ./cmd/taskd
# Clean build artifacts
clean:
rm -rf bin/ dist/
# Run tests with race detector
test:
go test -race ./...
# Run go vet
vet:
go vet ./...
# Run govulncheck
vuln:
govulncheck ./...
# Run all checks: vet, vuln, lint, test
audit: vet vuln lint test
# Generate HTML coverage report
coverage:
go test -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
# Run the TUI locally (ty command)
run:
go run ./cmd/task
# Run the daemon locally
daemon:
go run ./cmd/taskd
# Deploy binary to server
deploy: build-linux
@echo "Deploying to $(SERVER)..."
scp bin/taskd-linux $(SERVER):$(REMOTE_DIR)/taskd
ssh $(SERVER) 'chmod +x $(REMOTE_DIR)/taskd && chown $(REMOTE_USER):$(REMOTE_USER) $(REMOTE_DIR)/taskd'
@echo "Restarting service..."
-ssh $(SERVER) 'systemctl restart taskd'
@echo "Done! Connect with: ssh -p 2222 cloud-claude"
# Install systemd service on server (first time only)
deploy-service:
./scripts/install-service.sh $(SERVER) $(REMOTE_USER) $(REMOTE_DIR)
# Full deployment (first time)
deploy-full: build-linux
@echo "Deploying binary..."
scp bin/taskd-linux $(SERVER):$(REMOTE_DIR)/taskd
ssh $(SERVER) 'chmod +x $(REMOTE_DIR)/taskd && chown $(REMOTE_USER):$(REMOTE_USER) $(REMOTE_DIR)/taskd'
@echo "Installing service..."
./scripts/install-service.sh $(SERVER) $(REMOTE_USER) $(REMOTE_DIR)
# Check server status
status:
ssh $(SERVER) 'systemctl status taskd'
# View server logs
logs:
ssh $(SERVER) 'journalctl -u taskd -f'
# Connect to the TUI
connect:
ssh -p 2222 cloud-claude
# Cut a new patch release (auto-increments from latest tag)
# Usage: make release → v0.2.21 becomes v0.2.22
# make release BUMP=minor → v0.2.21 becomes v0.3.0
# make release BUMP=major → v0.2.21 becomes v1.0.0
BUMP ?= patch
release:
@LATEST=$$(git tag -l 'v*' --sort=-v:refname | head -1); \
if [ -z "$$LATEST" ]; then LATEST="v0.0.0"; fi; \
MAJOR=$$(echo $$LATEST | sed 's/^v//' | cut -d. -f1); \
MINOR=$$(echo $$LATEST | sed 's/^v//' | cut -d. -f2); \
PATCH=$$(echo $$LATEST | sed 's/^v//' | cut -d. -f3); \
case "$(BUMP)" in \
major) MAJOR=$$((MAJOR+1)); MINOR=0; PATCH=0;; \
minor) MINOR=$$((MINOR+1)); PATCH=0;; \
patch) PATCH=$$((PATCH+1));; \
*) echo "Invalid BUMP=$(BUMP). Use patch, minor, or major."; exit 1;; \
esac; \
NEXT="v$$MAJOR.$$MINOR.$$PATCH"; \
echo "$$LATEST → $$NEXT"; \
git tag -a $$NEXT -m "Release $$NEXT" && \
git push origin $$NEXT && \
echo "Done! View at: https://github.com/bborn/taskyou/releases/tag/$$NEXT"
# Format code
fmt:
go fmt ./...
# Lint code
lint:
golangci-lint run
.DEFAULT_GOAL := build