-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
57 lines (44 loc) · 1.16 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
PROJ := "$(notdir $(shell pwd))"
BRANCH := "$(shell git rev-parse --abbrev-ref HEAD)"
STATUS := "$(shell git status -s)"
BUILD_OUTDIR = "dist"
BUILD_FILE_PATTERN := "${PROJ}_{{.OS}}_{{.Arch}}"
BUILD_ARCH = "amd64 arm64"
BUILD_OS = "linux darwin windows"
BUILD_LDFLAGS := "-s -w -X main.version=$(BRANCH)"
TAG_REGEX = "^v[0-9]\.[0-9]\.[0-9]$$"
export GO111MODULE=on
.PHONY: test
test:
go test ./...
.PHONY: tidy
tidy:
@go mod tidy
@sleep 1
.PHONY: credits
credits: tidy
@gocredits -w
@sleep 1
.PHONY: prepare
prepare: test tidy credits
.PHONY: build
build: test
gox -ldflags=${BUILD_LDFLAGS} -os=${BUILD_OS} -arch=${BUILD_ARCH} -output=${BUILD_OUTDIR}/${BRANCH}/${BUILD_FILE_PATTERN}
.PHONY: release
release: checkbranch checkstatus build
ghr "${BRANCH}" "${BUILD_OUTDIR}/${BRANCH}/"
.PHONY: checkbranch
checkbranch:
ifeq (${BRANCH}, "$(shell echo ${BRANCH} | grep ${TAG_REGEX})")
@echo "branch name ${BRANCH} successfully checked for release"
else
@echo "branch name ${BRANCH} does not follow semver naming convention, will not release"
@exit 1
endif
.PHONY: checkstatus
checkstatus:
ifneq (${STATUS}, "")
@echo "dirty branch: check git status"
@exit 1
endif
@: