-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (44 loc) · 1.22 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
BINARYNAME=go-blog
TMP=tmp
DIST=release
GITHASH=$(shell git rev-parse HEAD)
BUILD_VERSION=$(shell git describe --tags)
ifndef $(GOPATH)
GOPATH=$(shell go env GOPATH)
export GOPATH
endif
RELEASE="releases"
LDFLAGS=-ldflags '-X main.BuildVersion=${BUILD_VERSION} -X main.GitHash=${GITHASH}'
.PHONY: clean build-release build lint install package vet fmt test
build-release: clean tidy fmt vet test build package
build:
go build ${LDFLAGS} -o ${GOPATH}/bin/go-blog
cd clt/createuser && go build -o ${GOPATH}/bin/create_user ${LDFLAGS}
cd clt/initdatabase && go build -o ${GOPATH}/bin/init_database ${LDFLAGS}
install:
go install ${LDFLAGS}
cd clt/createuser && go install ${LDFLAGS}
cd clt/initdatabase && go install ${LDFLAGS}
package:
-rm -r ${TMP}
mkdir -p ${TMP}/clt
-mkdir -p releases/custom
cp ${GOPATH}/bin/go-blog ${TMP}/
cp ${GOPATH}/bin/create_user ${TMP}/clt
cp ${GOPATH}/bin/init_database ${TMP}/clt
cp go-blog.conf ${TMP}/
cp -r examples/ ${TMP}/
cp -r templates/ ${TMP}/
cp -r assets/ ${TMP}/
cp README.md ${TMP}/
cd ${TMP} && tar -czvf ../releases/$(BINARYNAME)-$(BUILD_VERSION).tar.gz * && cd -
vet:
go vet ./...
fmt:
go fmt ./...
test:
go test ./...
clean:
go clean -i ./...
tidy:
go mod tidy