This repository has been archived by the owner on Sep 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
71 lines (58 loc) · 2.57 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=hcloud-csi-driver
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/apricote/hcloud-csi-driver/driver.version=${VERSION} -X github.com/apricote/hcloud-csi-driver/driver.commit=${COMMIT} -X github.com/apricote/hcloud-csi-driver/driver.gitTreeState=${GIT_TREE_STATE}
PKG ?= github.com/apricote/hcloud-csi-driver/cmd/hcloud-csi-driver
## 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/hcloud-csi-driver-${VERSION}.yaml deploy/kubernetes/releases/hcloud-csi-driver-${NEW_VERSION}.yaml
@sed -i'' -e 's/${VERSION}/${NEW_VERSION}/g' deploy/kubernetes/releases/hcloud-csi-driver-${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/hcloud-csi-driver-${NEW_VERSION}.yaml-e
.PHONY: compile
compile:
@echo "==> Building the project"
@env CGO_ENABLED=0 GOOS=${OS} GOARCH=amd64 go build -o cmd/hcloud-csi-driver/${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 apricote/hcloud-csi-driver:$(VERSION) cmd/hcloud-csi-driver -f cmd/hcloud-csi-driver/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 apricote/hcloud-csi-driver:$(VERSION)"
@docker push apricote/hcloud-csi-driver:$(VERSION)
@echo "==> Your image is now available at apricote/hcloud-csi-driver:$(VERSION)"
endif
.PHONY: clean
clean:
@echo "==> Cleaning releases"
@GOOS=${OS} go clean -i -x ./...