This repository was archived by the owner on Nov 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathMakefile
More file actions
76 lines (58 loc) · 1.88 KB
/
Makefile
File metadata and controls
76 lines (58 loc) · 1.88 KB
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
LAST_TAG := $(shell git describe --abbrev=0 --tags 2>/dev/null || git rev-parse --short HEAD)
USER := redhat-cop
EXECUTABLE := template2helm
# only include the amd64 binaries, otherwise the github release will become
# too big
UNIX_EXECUTABLES := \
mac-amd64-$(EXECUTABLE) \
linux-amd64-$(EXECUTABLE)
WIN_EXECUTABLES := \
windows-amd64-$(EXECUTABLE).exe
COMPRESSED_EXECUTABLES=$(UNIX_EXECUTABLES:%=%.bz2) $(WIN_EXECUTABLES:%.exe=%.zip)
COMPRESSED_EXECUTABLE_TARGETS=$(COMPRESSED_EXECUTABLES:%=bin/%)
BUILD_ARGS = -ldflags "-X github.com/$(USER)/$(EXECUTABLE)/cmd.version=$(LAST_TAG)"
all: $(EXECUTABLE)
# arm
#bin/linux-arm-5-$(EXECUTABLE):
# GOARM=5 GOARCH=arm GOOS=linux go build -o "$@" $(BUILD_ARGS)
#bin/linux-arm-7-$(EXECUTABLE):
# GOARM=7 GOARCH=arm GOOS=linux go build -o "$@" $(BUILD_ARGS)
# 386
#bin/darwin-386-$(EXECUTABLE):
# GOARCH=386 GOOS=darwin go build -o "$@" $(BUILD_ARGS)
#bin/linux-386-$(EXECUTABLE):
# GOARCH=386 GOOS=linux go build -o "$@" $(BUILD_ARGS)
#bin/windows-386-$(EXECUTABLE):
# GOARCH=386 GOOS=windows go build -o "$@" $(BUILD_ARGS)
# amd64
bin/mac-amd64-$(EXECUTABLE):
GOARCH=amd64 GOOS=darwin go build -o "$@" $(BUILD_ARGS)
bin/linux-amd64-$(EXECUTABLE):
GOARCH=amd64 GOOS=linux go build -o "$@" $(BUILD_ARGS)
bin/windows-amd64-$(EXECUTABLE).exe:
GOARCH=amd64 GOOS=windows go build -o "$@" $(BUILD_ARGS)
# compressed artifacts, makes a huge difference (Go executable is ~9MB,
# after compressing ~2MB)
%.bz2: %
bzip2 -c < "$<" > "$@"
%.zip: %.exe
zip "$@" "$<"
# git tag -a v$(RELEASE) -m 'release $(RELEASE)'
release: clean
$(MAKE) $(COMPRESSED_EXECUTABLE_TARGETS)
dep:
go mod vendor
$(EXECUTABLE): dep
go build -o "$@" $(BUILD_ARGS)
install: clean all
go install
clean:
rm $(EXECUTABLE) || true
rm -rf bin/ || true
test: clean dep
go test ./...
test_e2e: install
test/e2e.sh
lint:
golangci-lint run
.PHONY: clean release dep install test test_e2e lint