This repository has been archived by the owner on Aug 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
76 lines (65 loc) · 2.79 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
WHAT ?= dash
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILDTIME ?= $(shell date '+%Y-%m-%d@%H:%M:%S')
BUILDUSER ?= $(shell id -un)
REPO ?= github.com/ricoberger/dash
REVISION ?= $(shell git rev-parse HEAD)
VERSION ?= $(shell git describe --tags)
.PHONY: build build-darwin-amd64 build-linux-amd64 build-windows-amd64 clean release release-major release-minor release-patch
build:
for target in $(WHAT); do \
go build -ldflags "-X ${REPO}/pkg/version.Version=${VERSION} \
-X ${REPO}/pkg/version.Revision=${REVISION} \
-X ${REPO}/pkg/version.Branch=${BRANCH} \
-X ${REPO}/pkg/version.BuildUser=${BUILDUSER} \
-X ${REPO}/pkg/version.BuildDate=${BUILDTIME}" \
-o ./bin/$$target ./cmd/$$target; \
done
build-darwin-amd64:
for target in $(WHAT); do \
CGO_ENABLED=0 GOARCH=amd64 GOOS=darwin go build -a -installsuffix cgo -ldflags "-X ${REPO}/pkg/version.Version=${VERSION} \
-X ${REPO}/pkg/version.Revision=${REVISION} \
-X ${REPO}/pkg/version.Branch=${BRANCH} \
-X ${REPO}/pkg/version.BuildUser=${BUILDUSER} \
-X ${REPO}/pkg/version.BuildDate=${BUILDTIME}" \
-o ./bin/$$target-darwin-amd64 ./cmd/$$target; \
done
build-linux-amd64:
for target in $(WHAT); do \
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -a -installsuffix cgo -ldflags "-X ${REPO}/pkg/version.Version=${VERSION} \
-X ${REPO}/pkg/version.Revision=${REVISION} \
-X ${REPO}/pkg/version.Branch=${BRANCH} \
-X ${REPO}/pkg/version.BuildUser=${BUILDUSER} \
-X ${REPO}/pkg/version.BuildDate=${BUILDTIME}" \
-o ./bin/$$target-linux-amd64 ./cmd/$$target; \
done
build-windows-amd64:
for target in $(WHAT); do \
CGO_ENABLED=0 GOARCH=amd64 GOOS=windows go build -a -installsuffix cgo -ldflags "-X ${REPO}/pkg/version.Version=${VERSION} \
-X ${REPO}/pkg/version.Revision=${REVISION} \
-X ${REPO}/pkg/version.Branch=${BRANCH} \
-X ${REPO}/pkg/version.BuildUser=${BUILDUSER} \
-X ${REPO}/pkg/version.BuildDate=${BUILDTIME}" \
-o ./bin/$$target-windows-amd64.exe ./cmd/$$target; \
done
clean:
rm -rf ./bin
release: clean build-darwin-amd64 build-linux-amd64 build-windows-amd64
release-major:
$(eval MAJORVERSION=$(shell git describe --tags --abbrev=0 | sed s/v// | awk -F. '{print $$1+1".0.0"}'))
git checkout master
git pull
git tag -a $(MAJORVERSION) -m 'Release $(MAJORVERSION)'
git push origin --tags
release-minor:
$(eval MINORVERSION=$(shell git describe --tags --abbrev=0 | sed s/v// | awk -F. '{print $$1"."$$2+1".0"}'))
git checkout master
git pull
git tag -a $(MINORVERSION) -m 'Release $(MINORVERSION)'
git push origin --tags
release-patch:
$(eval PATCHVERSION=$(shell git describe --tags --abbrev=0 | sed s/v// | awk -F. '{print $$1"."$$2"."$$3+1}'))
git checkout master
git pull
git tag -a $(PATCHVERSION) -m 'Release $(PATCHVERSION)'
git push origin --tags