-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.release
50 lines (44 loc) · 2.33 KB
/
Makefile.release
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
ifeq (, $(shell which curl))
$(error "No curl in $$PATH, please install")
endif
NAME:=coredns
VERSION:=$(shell grep 'CoreVersion' coremain/version.go | awk '{ print $$3 }' | tr -d '"')
PLUGIN_VERSION:=$(shell grep 'PluginVersion' plugin/dnsimple/version.go | awk '{ print $$3 }' | tr -d '"')
GITCOMMIT:=$(shell git describe --dirty --always)
LINUX_ARCH:=amd64 arm arm64
release: build tar
.PHONY: build
build:
@rm -rf build && mkdir build
@echo "Building: darwin/amd64 - $(VERSION) - $(PLUGIN_VERSION)"
@mkdir -p build/darwin/amd64
@GOOS=darwin GOARCH=amd64 go build -o build/darwin/amd64/$(NAME) -ldflags="-s -w -X github.com/coredns/coredns/coremain.GitCommit=$(GITCOMMIT)"
@echo "Building: darwin/arm64 - $(VERSION) - $(PLUGIN_VERSION)"
@mkdir -p build/darwin/arm64
@GOOS=darwin GOARCH=arm64 go build -o build/darwin/arm64/$(NAME) -ldflags="-s -w -X github.com/coredns/coredns/coremain.GitCommit=$(GITCOMMIT)"
@echo "Building: windows/amd64 - $(VERSION) - $(PLUGIN_VERSION)"
@mkdir -p build/windows/amd64
@GOOS=windows GOARCH=amd64 go build -o build/windows/amd64/$(NAME).exe -ldflags="-s -w -X github.com/coredns/coredns/coremain.GitCommit=$(GITCOMMIT)"
@echo Building: linux/$(LINUX_ARCH) - $(VERSION) - $(PLUGIN_VERSION) ;\
for arch in $(LINUX_ARCH); do \
mkdir -p build/linux/$$arch && GOOS=linux GOARCH=$$arch go build -o build/linux/$$arch/$(NAME) -ldflags="-s -w -X github.com/coredns/coredns/coremain.GitCommit=$(GITCOMMIT)" ;\
done
.PHONY: tar
tar:
@rm -rf release && mkdir release
tar -zcf release/$(NAME)_$(VERSION)_dnsimple_$(PLUGIN_VERSION)_darwin_amd64.tar.gz -C build/darwin/amd64 $(NAME)
tar -zcf release/$(NAME)_$(VERSION)_dnsimple_$(PLUGIN_VERSION)_darwin_arm64.tar.gz -C build/darwin/arm64 $(NAME)
tar -zcf release/$(NAME)_$(VERSION)_dnsimple_$(PLUGIN_VERSION)_windows_amd64.tar.gz -C build/windows/amd64 $(NAME).exe
for arch in $(LINUX_ARCH); do \
tar -zcf release/$(NAME)_$(VERSION)_dnsimple_$(PLUGIN_VERSION)_linux_$$arch.tar.gz -C build/linux/$$arch $(NAME) ;\
done
.PHONY: build-linux
build-linux:
@rm -rf build && mkdir build
@echo "Building: linux/$(ARCH) - $(VERSION) - $(PLUGIN_VERSION)"
@mkdir -p build/linux/$(ARCH)
@GOOS=linux GOARCH=$(ARCH) go build -o build/linux/$(ARCH)/$(NAME) -ldflags="-s -w -X github.com/coredns/coredns/coremain.GitCommit=$(GITCOMMIT)"
.PHONY: clean
clean:
rm -rf release
rm -rf build