-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (55 loc) · 1.82 KB
/
Makefile
File metadata and controls
71 lines (55 loc) · 1.82 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
.PHONY: build run clean test deps help docker-build pull push
# Detect OS and arch
UNAME_S := $(shell uname -s)
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_S),Darwin)
OS := macos
CGO_CFLAGS := -I/opt/homebrew/include
CGO_LDFLAGS := -L/opt/homebrew/lib
else
OS := linux
CGO_CFLAGS :=
CGO_LDFLAGS :=
endif
ifeq ($(UNAME_M),arm64)
ARCH := arm64
else ifeq ($(UNAME_M),aarch64)
ARCH := arm64
else
ARCH := amd64
endif
BINARY := ash-$(OS)-$(ARCH)
help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
deps: ## Install Go dependencies
go mod download
go mod tidy
build: ## Build the ash binary (builds package)
CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" go build -o $(BINARY) ./cmd/ash
run: build ## Build and run the ash single-file binary
./$(BINARY)
clean: ## Remove built binaries and generated files
rm -f ash-*-*
rm -rf ./data/*
test: ## Run tests
go test ./...
cd test && go test -v
docker-build: ## Build using Docker for cross-compilation to Ubuntu
docker build --platform linux/amd64 -t ash .
docker run --rm -v $(PWD):/host ash cp /usr/local/bin/ash /host/ash-linux-amd64
# Sync configuration
RSYNC_OPTS ?= -avzhP --delete
REMOTE_DATA ?= ark:ash/data/
pull: ## Pull remote db into local ./data/ (stops remote bot first)
ssh ark sudo systemctl stop ash.service
@mkdir -p data
rsync $(RSYNC_OPTS) $(REMOTE_DATA) ./data/
push: ## Push local ./data/ to remote (restarts remote bot after)
rsync $(RSYNC_OPTS) ./data/ $(REMOTE_DATA)
rsync -avzP *.json 'ark:ash'
ssh ark sudo systemctl restart ash.service
.DEFAULT_GOAL := run
ci: docker-build
rsync -avzP ash-linux-amd64 'ark:ash/ash-linux-amd64'
rsync -avzP *.json 'ark:ash'
ssh ark sudo systemctl restart ash.service