-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
52 lines (43 loc) · 1.31 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
# environment variables
BINARY := timelock-worker
PACKAGE := github.com/smartcontractkit/timelock-worker
VERSION := $(shell git describe --tags --always --abbrev=0 --match='v[0-9]*.[0-9]*.[0-9]*' 2> /dev/null | sed 's/^.//')
COMMIT_HASH := $(shell git rev-parse HEAD)
LDFLAGS := "-X $(PACKAGE)/cmd.Version=$(VERSION) -X $(PACKAGE)/cmd.Commit=$(COMMIT_HASH) -w -s"
VERSION := "v0.0.1"
# Folders
BIN_FOLDER := bin
SCRIPTS_F := scripts
# assets
C_GREEN=\033[0;32m
C_RED=\033[0;31m
C_BLUE=\033[0;34m
C_END=\033[0m
##########
# builds #
##########
.PHONY: all
all: clean test build
.PHONY: clean
clean:
@echo "\n\t$(C_GREEN)# Cleaning environment$(C_END)"
go clean -x
rm -rf $(BIN_FOLDER)
rm -f $(SCRIPTS_F)/report.html
.PHONY: test
test:
@echo "\n\t$(C_GREEN)# Run test and generate new coverage.out$(C_END)"
go test -short -coverprofile=coverage.out -covermode=atomic -race ./...
.PHONY: coverage
coverage:
@echo "\n\t$(C_GREEN)# View coverage.out report$(C_END)"
@go tool cover -html="coverage.out"
.PHONY: build
build: clean
@echo "\n\t$(C_GREEN)# Build binary $(BINARY)$(C_END)"
go build -trimpath -ldflags $(LDFLAGS) -o $(BIN_FOLDER)/$(BINARY) main.go
.PHONY: release
release:
@echo "\n\t$(C_GREEN)# Creating release $(VERSION) $(C_END)"
git tag -s $(VERSION) -m $(VERSION)
git push origin $(VERSION)