-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (58 loc) · 2.55 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
NAME=pb-csi-plugin
OS ?= linux
ifeq ($(strip $(shell git status --porcelain 2>/dev/null)),)
GIT_TREE_STATE=clean
else
GIT_TREE_STATE=dirty
endif
COMMIT ?= $(shell git rev-parse HEAD)
BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
LDFLAGS ?= -X github.com/profitbricks/csi-profitbricks/driver.version=${VERSION} -X github.com/profitbricks/csi-profitbricks/driver.commit=${COMMIT} -X github.com/profitbricks/csi-profitbricks/driver.gitTreeState=${GIT_TREE_STATE}
PKG ?= github.com/profitbricks/csi-profitbricks/cmd/pb-csi-plugin
## Bump the version in the version file. Set BUMP to [ patch | major | minor ]
BUMP := patch
VERSION ?= $(shell cat VERSION)
all: test
publish: compile build push clean
.PHONY: bump-version
bump-version:
@go get -u github.com/jessfraz/junk/sembump # update sembump tool
$(eval NEW_VERSION = $(shell sembump --kind $(BUMP) $(VERSION)))
@echo "Bumping VERSION from $(VERSION) to $(NEW_VERSION)"
@echo $(NEW_VERSION) > VERSION
@cp deploy/kubernetes/releases/csi-profitbricks-${VERSION}.yaml deploy/kubernetes/releases/csi-profitbricks-${NEW_VERSION}.yaml
@sed -i'' -e 's/${VERSION}/${NEW_VERSION}/g' deploy/kubernetes/releases/csi-profitbricks-${NEW_VERSION}.yaml
@sed -i'' -e 's/${VERSION}/${NEW_VERSION}/g' README.md
$(eval NEW_DATE = $(shell date +%Y.%m.%d))
@sed -i'' -e 's/## unreleased/## ${NEW_VERSION} - ${NEW_DATE}/g' CHANGELOG.md
@ echo '## unreleased\n' | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md
@rm README.md-e CHANGELOG.md-e deploy/kubernetes/releases/csi-profitbricks-${NEW_VERSION}.yaml-e
.PHONY: compile
compile:
@echo "==> Building the project"
@env CGO_ENABLED=0 GOOS=${OS} GOARCH=amd64 go build -o cmd/pb-csi-plugin/${NAME} -ldflags "$(LDFLAGS)" ${PKG}
.PHONY: test
test:
@echo "==> Testing all packages"
@go test -v ./...
.PHONY: test-integration
test-integration:
@echo "==> Started integration tests"
@env GOCACHE=off go test -v -tags integration ./test/...
.PHONY: build
build:
@echo "==> Building the docker image"
@docker build -t profitbricks/pb-csi-plugin:$(VERSION) cmd/pb-csi-plugin -f cmd/pb-csi-plugin/Dockerfile
.PHONY: push
push:
ifeq ($(shell [[ $(BRANCH) != "master" && $(VERSION) != "dev" ]] && echo true ),true)
@echo "ERROR: Publishing image with a SEMVER version '$(VERSION)' is only allowed from master"
else
@echo "==> Publishing profitbricks/pb-csi-plugin:$(VERSION)"
@docker push profitbricks/pb-csi-plugin:$(VERSION)
@echo "==> Your image is now available at profitbricks/pb-csi-plugin:$(VERSION)"
endif
.PHONY: clean
clean:
@echo "==> Cleaning releases"
@GOOS=${OS} go clean -i -x ./...