forked from probr/probr-pack-wireframe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (47 loc) · 2.02 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
PACKNAME=wireframe
BUILD_FLAGS=-X 'main.GitCommitHash=`git rev-parse --short HEAD`' -X 'main.BuiltAt=`date +%FT%T%z`'
BUILD_WIN=@env GOOS=windows GOARCH=amd64 go build -o $(PACKNAME).exe
BUILD_LINUX=@env GOOS=linux GOARCH=amd64 go build -o $(PACKNAME)
BUILD_MAC=@env GOOS=darwin GOARCH=amd64 go build -o $(PACKNAME)-darwin
release: go-package go-release pkgr-clean
release-candidate: go-package go-release-candidate pkgr-clean
binary: go-package go-build pkgr-clean
go-release: release-nix release-win release-mac
go-build:
@echo " > Building binary ..."
@go build -o $(PACKNAME) -ldflags="$(BUILD_FLAGS)"
go-package: go-tidy go-test
@echo " > Packaging static files..."
@pkger
pkgr-clean:
@echo " > Removing pkged.go to avoid accidental re-use of old files..."
@rm pkged.go
go-test:
@echo " > Validating code ..."
@golint ./...
@go vet ./...
@go test ./...
go-tidy:
@echo " > Tidying go.mod ..."
@go mod tidy
go-test-cov:
@echo "Running tests and generating coverage output ..."
@go test ./... -coverprofile coverage.out -covermode count
@sleep 2 # Sleeping to allow for coverage.out file to get generated
@echo "Current test coverage : $(shell go tool cover -func=coverage.out | grep total | grep -Eo '[0-9]+\.[0-9]+') %"
go-release-candidate: go-tidy go-test
@echo " > Building release candidate for Linux..."
$(BUILD_LINUX) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=nix-rc'"
@echo " > Building release candidate for Windows..."
$(BUILD_WIN) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=win-rc'"
@echo " > Building release for Darwin..."
$(BUILD_MAC) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=darwin-rc'"
release-nix:
@echo " > Building release for Linux..."
$(BUILD_LINUX) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=linux'"
release-win:
@echo " > Building release for Windows..."
$(BUILD_WIN) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=windows'"
release-mac:
@echo " > Building release for Darwin..."
$(BUILD_MAC) -ldflags="$(BUILD_FLAGS) -X 'main.VersionPostfix=darwin'"