-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathjustfile
More file actions
64 lines (50 loc) · 1.41 KB
/
justfile
File metadata and controls
64 lines (50 loc) · 1.41 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
run *args:
go run cmd/sandworm/main.go {{args}}
fmt:
go fmt ./...
go run golang.org/x/tools/cmd/goimports@latest -w .
test *args:
go test -v -race -cover ./... {{args}}
lint:
golangci-lint run ./...
build:
go build -o bin/sandworm ./cmd/sandworm
update-deps:
# Update deps to their latest compatible versions
go get -u ./...
go mod tidy
install:
#!/usr/bin/env sh
set -euo pipefail
# Determine OS and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
ARCH="amd64"
elif [ "$ARCH" = "arm64" ]; then
ARCH="arm64"
fi
# Clean dist and build binary snapshot for local use
goreleaser build --clean --snapshot
# Assume v8.0 (x86-64-v3) since it has better performance in modern CPUs (at
# the cost of compatibility with older CPUs)
BINARY="dist/sandworm_${OS}_${ARCH}_v8.0/sandworm"
# Overzealous check; if build above succeeded, binary should exist.
if [ ! -f "$BINARY" ]; then
echo "Error: Binary not found at $BINARY" >&2
exit 1
fi
# Install as sandworm-dev to $GOBIN
# (allows coexisting with the real sandworm binary elsewhere in PATH)
BIN_PATH="$(go env GOBIN)"
if [ -z "$BIN_PATH" ]; then
echo "Error: GOBIN is not set" >&2
exit 1
fi
echo "Installing to $BIN_PATH/sandworm-dev..." >&2
cp "$BINARY" "$BIN_PATH/sandworm-dev"
chmod +x "$BIN_PATH/sandworm-dev"
uninstall:
rm -f "$(go env GOBIN)/sandworm-dev"
clean:
rm -rf bin/ dist/