-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
77 lines (60 loc) · 2.09 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
ARCH?=amd64
OUT_DIR?=./_output
DOCKER_REPO?=wavefronthq
DOCKER_IMAGE?=wavefront-hpa-adapter
# Represents the upcoming version
# whereas the current version is referenced in the
# deploy/manifests/05-custom-metrics-apiserver-deployment.yaml file
#
# IMPORTANT: This is also overwritten by the release pipeline build with parameters
VERSION?=0.9.16
BINARY_NAME=wavefront-adapter
GIT_COMMIT:=$(shell git rev-parse --short HEAD)
GOOS?=$(shell go env GOOS)
GOARCH?=$(shell go env GOARCH)
REPO_DIR:=$(shell pwd)
ifndef TEMP_DIR
TEMP_DIR:=$(shell mktemp -d /tmp/wavefront.XXXXXX)
endif
# for testing, the built image will also be tagged with this name
OVERRIDE_IMAGE_NAME?=$(ADAPTER_TEST_IMAGE)
LDFLAGS=-w -X main.version=$(VERSION) -X main.commit=$(GIT_COMMIT)
.PHONY: all
all: build
.PHONY: fmt
fmt:
find . -type f -name "*.go" | grep -v "./vendor*" | xargs gofmt -s -w
.PHONY: build
build:
CGO_ENABLED=0 GOARCH=$(GOARCH) go build -ldflags "$(LDFLAGS)" -a -tags netgo -o build/$(GOOS)/$(GOARCH)/$(BINARY_NAME) ./cmd/wavefront-adapter/
.PHONY: test
test:
CGO_ENABLED=0 go test ./pkg/...
.PHONY: lint
lint:
go vet -composites=false ./...
BUILDER_SUFFIX=$(shell echo $(PREFIX) | cut -d '/' -f1)
.PHONY: publish
publish:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build -o fmt -o vet
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 make build -o fmt -o vet
docker buildx create --use --node wavefront_k8s_adapter_builder_$(BUILDER_SUFFIX)
docker buildx build --platform linux/amd64,linux/arm64 --push --pull -t $(DOCKER_REPO)/$(DOCKER_IMAGE):$(VERSION) -t $(DOCKER_REPO)/$(DOCKER_IMAGE):latest -f Dockerfile build
.PHONY: clean
clean:
rm -rf $(OUT_DIR)
# create a new bump version branch
.PHONY: branch
branch:
git stash
git checkout master
git pull
git checkout -b bump-version-$(VERSION)
.PHONY: update-version
update-version:
@if [ -z "$(NEW_VERSION)" ]; then echo "Need to set NEW_VERSION" && exit 1; fi
git add Makefile
git add release/VERSION
git add deploy/manifests/05-custom-metrics-apiserver-deployment.yaml
git commit -m "Bump version to $(NEW_VERSION)"
git push --set-upstream origin bump-version-$(NEW_VERSION)