-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
89 lines (76 loc) · 2.72 KB
/
Makefile
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
BINARY_NAME = xmr-nodes
# These build are modified version of rclone's Makefile
# https://github.com/rclone/rclone/blob/master/Makefile
VERSION := $(shell cat VERSION)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
# Last tag on this branch (eg. v1.0.0)
LAST_TAG := $(shell git describe --tags --abbrev=0)
# Tag of the current commit, if any. If this is not "" then we are building a release
RELEASE_TAG := $(shell git tag -l --points-at HEAD)
# If we are working on a release, override branch to main
ifdef RELEASE_TAG
BRANCH := main
LAST_TAG := $(shell git describe --abbrev=0 --tags $(VERSION)^)
endif
# Make version suffix -beta.NNNN.CCCCCCCC (N=Commit number, C=Commit)
VERSION_SUFFIX := -beta.$(shell git rev-list --count HEAD).$(shell git show --no-patch --no-notes --pretty='%h' HEAD)
TAG_BRANCH := .$(BRANCH)
# If building HEAD or master then unset TAG_BRANCH
ifeq ($(subst HEAD,,$(subst main,,$(BRANCH))),)
TAG_BRANCH :=
endif
# TAG is current version + commit number + commit + branch
TAG := $(VERSION)$(VERSION_SUFFIX)$(TAG_BRANCH)
ifdef RELEASE_TAG
TAG := $(RELEASE_TAG)
endif
# end modified rclone's Makefile
BUILD_LDFLAGS := -s -w -X github.com/ditatompel/xmr-remote-nodes/internal/config.Version=$(TAG)
# This called from air cmd (see .air.toml)
.PHONY: dev
dev:
go build -ldflags="$(BUILD_LDFLAGS)" -tags server -o ./tmp/main .
.PHONY: build
build: client server
.PHONY: ui
ui:
go generate ./...
.PHONY: client
client:
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build \
-ldflags="$(BUILD_LDFLAGS)" \
-o bin/${BINARY_NAME}-client-linux-amd64
CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build \
-ldflags="$(BUILD_LDFLAGS)" \
-o bin/${BINARY_NAME}-client-linux-arm64
.PHONY: server
server: ui
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build \
-ldflags="$(BUILD_LDFLAGS)" -tags server \
-o bin/${BINARY_NAME}-server-linux-amd64
CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build \
-ldflags="$(BUILD_LDFLAGS)" -tags server \
-o bin/${BINARY_NAME}-server-linux-arm64
.PHONY: clean
clean:
go clean
rm -rfv ./bin
rm -rf ./frontend/build
.PHONY: lint
lint:
golangci-lint run ./...
.PHONY: test
test:
go test -race -cover ./...
.PHONY: bench
bench:
go test ./... -bench=. -benchmem -run=^#
# Deploying new binary file to server and probers host
# The deploy-* command doesn't build the binary file, so you need to run `make build` first.
# And make sure the inventory and deploy-*.yml file is properly configured.
.PHONY: deploy-server
deploy-server:
ansible-playbook -i ./deployment/ansible/inventory.ini -l server ./deployment/ansible/deploy-server.yml -K
.PHONY: deploy-prober
deploy-prober:
ansible-playbook -i ./deployment/ansible/inventory.ini -l prober ./deployment/ansible/deploy-prober.yml -K