forked from uselagoon/lagoon-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
115 lines (96 loc) · 3.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
DIR := $(PWD)
GOCMD=go
ARTIFACT_NAME=lagoon
ARTIFACT_DESTINATION=$(GOPATH)/bin
PKG=github.com/amazeeio/lagoon-cli
PKGMODPATH=$(DIR)/vendor
VERSION=$(shell ${PWD}/increment_ver.sh -p $(shell git describe --abbrev=0 --tags))-rc
BUILD=$(shell date +%FT%T%z)
DOCKER_GO_VER=1.14
GO_VER=$(shell go version)
LDFLAGS=-w -s -X ${PKG}/cmd.lagoonCLIVersion=${VERSION} -X ${PKG}/cmd.lagoonCLIBuild=${BUILD}
GIT_ORIGIN=origin
all: deps test build docs
all-docker-linux: deps-docker test-docker build-docker-linux
all-docker-darwin: deps-docker test-docker build-docker-darwin
deps:
GO111MODULE=on ${GOCMD} get -v
test:
GO111MODULE=on $(GOCMD) fmt ./...
GO111MODULE=on $(GOCMD) vet ./...
GO111MODULE=on $(GOCMD) test -v ./...
gen:
GO111MODULE=on $(GOCMD) generate ./...
clean:
$(GOCMD) clean
build:
GO111MODULE=on CGO_ENABLED=0 $(GOCMD) build -ldflags '${LDFLAGS} -X "${PKG}/cmd.lagoonCLIBuildGoVersion=${GO_VER}"' -o ${ARTIFACT_DESTINATION}/${ARTIFACT_NAME} -v
build-linux:
GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOCMD) build -ldflags '${LDFLAGS} -X "${PKG}/cmd.lagoonCLIBuildGoVersion=${GO_VER}"' -o builds/lagoon-cli-${VERSION}-linux-amd64 -v
build-darwin:
GO111MODULE=on CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOCMD) build -ldflags '${LDFLAGS} -X "${PKG}/cmd.lagoonCLIBuildGoVersion=${GO_VER}"' -o builds/lagoon-cli-${VERSION}-darwin-amd64 -v
docs: test
GO111MODULE=on $(GOCMD) run main.go --docs
tidy:
GO111MODULE=on $(GOCMD) mod tidy
## build using docker golang
deps-docker:
docker run \
-v $(PKGMODPATH):/go/pkg/mod \
-v $(DIR):/go/src/${PKG}/ \
-e GO111MODULE=on \
-e GOOS=linux \
-e GOARCH=amd64 \
-w="/go/src/${PKG}/" \
golang:$(DOCKER_GO_VER) go get -v
## build using docker golang
test-docker:
docker run \
-v $(PKGMODPATH):/go/pkg/mod \
-v $(DIR):/go/src/${PKG}/ \
-e GO111MODULE=on \
-e GOOS=linux \
-e GOARCH=amd64 \
-w="/go/src/${PKG}/" \
golang:$(DOCKER_GO_VER) /bin/bash -c " \
go fmt ./... && \
go vet ./... && \
go test -v ./..."
## build using docker golang
build-docker-linux:
docker run \
-v $(PKGMODPATH):/go/pkg/mod \
-v $(DIR):/go/src/${PKG}/ \
-e GO111MODULE=on \
-e GOOS=linux \
-e GOARCH=amd64 \
-w="/go/src/${PKG}/" \
golang:$(DOCKER_GO_VER) go build -ldflags '${LDFLAGS} -X "${PKG}/cmd.lagoonCLIBuildGoVersion=${GO_VER}"' -o builds/lagoon-cli-${VERSION}-linux-amd64
build-docker-darwin:
docker run \
-v $(PKGMODPATH):/go/pkg/mod \
-v $(DIR):/go/src/${PKG}/ \
-e GO111MODULE=on \
-e GOOS=darwin \
-e GOARCH=amd64 \
-w="/go/src/${PKG}/" \
golang:$(DOCKER_GO_VER) go build -ldflags '${LDFLAGS} -X "${PKG}/cmd.lagoonCLIBuildGoVersion=${GO_VER}"' -o builds/lagoon-cli-${VERSION}-darwin-amd64
install-linux:
cp builds/lagoon-cli-${VERSION}-linux-amd64 ${ARTIFACT_DESTINATION}/lagoon
install-darwin:
cp builds/lagoon-cli-${VERSION}-darwin-amd64 ${ARTIFACT_DESTINATION}/lagoon
release-patch:
$(eval VERSION=$(shell ${PWD}/increment_ver.sh -p $(shell git describe --abbrev=0 --tags)))
git tag $(VERSION)
mkdocs gh-deploy
git push $(GIT_ORIGIN) master --tags
release-minor:
$(eval VERSION=$(shell ${PWD}/increment_ver.sh -m $(shell git describe --abbrev=0 --tags)))
git tag $(VERSION)
mkdocs gh-deploy
git push $(GIT_ORIGIN) master --tags
release-major:
$(eval VERSION=$(shell ${PWD}/increment_ver.sh -M $(shell git describe --abbrev=0 --tags)))
git tag $(VERSION)
mkdocs gh-deploy
git push $(GIT_ORIGIN) master --tags