-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
78 lines (61 loc) · 2.63 KB
/
justfile
File metadata and controls
78 lines (61 loc) · 2.63 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
# switchboard justfile
set dotenv-load
set dotenv-filename := ".env.local"
VERSION := env("VERSION", "dev")
# ─── Core recipes ─────────────────────────────────────────────
# Build the binary
build:
go build -ldflags "-X main.version={{VERSION}}" -o bin/switchboard ./cmd/switchboard
# Build and run
run: build
./bin/switchboard
# Remove build artifacts
clean:
rm -rf bin/
# Format with gofumpt
fmt:
gofumpt -w .
# Run golangci-lint
lint:
golangci-lint run ./...
# Run all tests
test:
go test ./... -v
# Run tests with race detector
test-race:
go test -race ./... -v
# Run tests in Docker
test-docker:
@command -v docker >/dev/null 2>&1 || { echo "Error: Docker is required but not found."; exit 1; }
@docker info >/dev/null 2>&1 || { echo "Error: Docker daemon is not running."; exit 1; }
@mkdir -p test-results
docker compose -f docker-compose.test.yml run --rm test
# ─── Cross-compile ────────────────────────────────────────────
# Build for all release targets
build-all:
GOOS=darwin GOARCH=arm64 go build -ldflags "-X main.version={{VERSION}}" -o bin/switchboard-darwin-arm64 ./cmd/switchboard
GOOS=darwin GOARCH=amd64 go build -ldflags "-X main.version={{VERSION}}" -o bin/switchboard-darwin-amd64 ./cmd/switchboard
GOOS=linux GOARCH=amd64 go build -ldflags "-X main.version={{VERSION}}" -o bin/switchboard-linux-amd64 ./cmd/switchboard
# ─── Signing & packaging ─────────────────────────────────────
# Codesign the binary
sign: (_require-var "APPLE_SIGNING_IDENTITY" env("APPLE_SIGNING_IDENTITY", ""))
codesign --force --options runtime --sign "${APPLE_SIGNING_IDENTITY}" --timestamp bin/switchboard
# Verify the codesign signature
verify:
codesign --verify --verbose=2 bin/switchboard
# ─── Internal helpers ─────────────────────────────────────────
# Check that an env var is set
[private]
_require-var name value:
#!/usr/bin/env bash
if [ -z "{{value}}" ]; then
echo "ERROR: {{name}} is not set."
echo ""
echo "To set up local signing:"
echo " 1. Copy .env.local.example to .env.local"
echo " 2. Fill in your values"
echo " 3. Run 'just sign-check' to find your signing identities"
echo ""
echo ".env.local is gitignored (*.env.* pattern)."
exit 1
fi