-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
55 lines (43 loc) · 1.35 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
NAME=release-tool
ROOT_DIR=$(shell pwd)
BUILD_DIR=${ROOT_DIR}/build
VERSION=$(shell cat VERSION)
BUILD_NUMBER=$(shell cat BUILD)
COMMIT=$(shell git rev-parse --short HEAD)
LD_FLAGS="-X main.RTVERSION=${VERSION} -X main.NAME=${NAME}"
.PHONY: all build clean fmt run bn
all: pre_build build post_build
pre_build: bn clean fmt
echo ${BUILD_NUMBER}
build:
mkdir -p ${ROOT_DIR}/build
GOOS=linux GOARCH=amd64 go build -ldflags ${LD_FLAGS} -o ${ROOT_DIR}/build/${NAME}-linux-amd64 ${ROOT_DIR}/src/*.go
GOOS=windows GOARCH=amd64 go build -ldflags ${LD_FLAGS} -o ${ROOT_DIR}/build/${NAME}-windows-amd64.exe ${ROOT_DIR}/src/*.go
GOOS=darwin GOARCH=amd64 go build -ldflags ${LD_FLAGS} -o ${ROOT_DIR}/build/${NAME}-macos-amd64 ${ROOT_DIR}/src/*.go
post_build:
@echo
@echo '##################################'
@echo ' OUTPUT FOR THE GIT RELEASE'
@echo '##################################'
@echo 'Version: `${VERSION}`'
@echo 'Build number: `${BUILD_NUMBER}`'
@echo 'Commit: `${COMMIT}`'
@echo
@echo 'SHA512 sum:'
@echo '```'
@cd ${BUILD_DIR} && sha512sum *
@echo '```'
@echo "##################################"
clean:
rm -rf ${ROOT_DIR}/build
vet:
go vet ${ROOT_DIR}/src/*.go
fmt:
go fmt ${ROOT_DIR}/src/*.go
test:
go test ${ROOT_DIR}/src/*.go -v
run:
go run ${ROOT_DIR}/src/*.go
bn:
@echo "${BUILD_NUMBER} + 1" | bc > BUILD
@BUILD_NUMBER=${BUILD_NUMBER}