generated from LinuxSuRen/.github
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
72 lines (52 loc) · 1.75 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
VERSION := $(shell git describe --tags $(shell git rev-list --tags --max-count=1))-next
COMMIT := $(shell git rev-parse --short HEAD)
BUILDFLAGS = -ldflags "-X github.com/linuxsuren/cobra-extension/version.version=$(VERSION) \
-X github.com/linuxsuren/cobra-extension/version.commit=$(COMMIT) \
-X github.com/linuxsuren/cobra-extension/version.date=$(shell date +'%Y-%m-%d') -w -s"
all: test build
.PHONY : all
simple-build:
CGO_ENABLE=0 go build $(BUILDFLAGS) -o bin/ks
build: pre-build simple-build
upx bin/ks
build-linux: pre-build
CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build $(BUILDFLAGS) -o bin/linux/ks
upx bin/linux/ks
build-plugin: pre-build
CGO_ENABLE=0 go build ${BUILDFLAGS} -o bin/kubectl-ks kubectl-plugin/*.go
upx bin/kubectl-ks
build-plugin-linux: pre-build
CGO_ENABLE=0 GOOS=linux GOARCH=amd64 go build ${BUILDFLAGS} -o bin/linux/kubectl-ks kubectl-plugin/*.go
upx bin/linux/kubectl-ks
pre-build: export GOPROXY=https://goproxy.io
pre-build: fmt lint mod-tidy
tools: export GOPROXY=https://goproxy.io
tools:
go get -u golang.org/x/lint/golint
test: test-without-lint lint
test-without-lint: fmt mod-tidy
go test ./... -coverprofile coverage.out
benchmark:
go test -bench=. -run=none ./...
mod-tidy:
go mod tidy -e
fmt:
go fmt ./...
lint:
golint -set_exit_status ./...
copy: build
sudo cp bin/ks /usr/local/bin/ks
simple-copy: simple-build
sudo cp bin/ks /usr/local/bin/ks
copy-plugin: build-plugin
sudo cp bin/kubectl-ks /usr/local/bin/kubectl-ks
goreleaser-test:
goreleaser release --rm-dist --skip-publish --snapshot
image: build-linux
cp bin/linux/ks build/ks
docker build ./build -t kubespheredev/ks-tool
image-push:
docker push kubespheredev/ks-tool
update:
git fetch
git reset --hard origin/$(shell git branch --show-current)