-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
76 lines (60 loc) · 2.64 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
BINARY_NAME=punq
GO=go
GOBUILD=$(GO) build
GOCLEAN=$(GO) clean
GOGET=$(GO) get
CGO_ENABLED=0
# Ensure linker embeds versioning information
VERSION=${shell git describe --tags $(git rev-list --tags --max-count=1)}
COMMIT_HASH=$(shell git rev-parse --short HEAD)
GIT_BRANCH=$(shell git rev-parse --abbrev-ref HEAD)
OPERATOR_IMAGE=$(shell echo "ghcr.io/mogenius/punq:$(VERSION)")
BUILD_TIMESTAMP=$(shell date)
ifeq ($(GIT_BRANCH),develop)
OPERATOR_IMAGE=$(shell echo "ghcr.io/mogenius/punq-dev:$(VERSION)")
endif
LDFLAGS=-s -w -extldflags= \
-X 'github.com/mogenius/punq/version.GitCommitHash=$(COMMIT_HASH)' \
-X 'github.com/mogenius/punq/version.OperatorImage=${OPERATOR_IMAGE}' \
-X 'github.com/mogenius/punq/version.Branch=$(GIT_BRANCH)' \
-X 'github.com/mogenius/punq/version.BuildTimestamp=$(BUILD_TIMESTAMP)' \
-X 'github.com/mogenius/punq/version.Ver=$(VERSION)'
all: darwin_arm64 darwin_amd64 linux_amd64 linux_386 linux_arm64 linux_arm windows_amd64 windows_386
tarballs: all
for file in builds/*; do \
tar -czvf builds/`basename "$$file"`.tar.gz -C builds `basename "$$file"`; \
done
update-frontend:
@curl https://github.com/mogenius/punq-frontend/releases/download/latest/latest.tar.gz -L -o ui.tar.gz
@mkdir -p ui/dist
@tar -xzf ui.tar.gz -C ui/dist
@rm ui.tar.gz
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)-$(VERSION)-darwin-amd64
rm -f $(BINARY_NAME)-$(VERSION)-darwin-386
rm -f $(BINARY_NAME)-$(VERSION)-linux-amd64
rm -f $(BINARY_NAME)-$(VERSION)-linux-386
rm -f $(BINARY_NAME)-$(VERSION)-linux-arm64
rm -f $(BINARY_NAME)-$(VERSION)-linux-arm
rm -f $(BINARY_NAME)-$(VERSION)-windows-amd64
rm -f $(BINARY_NAME)-$(VERSION)-windows-386
darwin_arm64:
GOOS=darwin GOARCH=arm64 $(GOBUILD) -ldflags="$(LDFLAGS)" -o builds/$(BINARY_NAME)-$(VERSION)-darwin-arm64 -v
darwin_amd64:
GOOS=darwin GOARCH=amd64 $(GOBUILD) -ldflags="$(LDFLAGS)" -o builds/$(BINARY_NAME)-$(VERSION)-darwin-amd64 -v
linux_amd64:
GOOS=linux GOARCH=amd64 $(GOBUILD) -ldflags="$(LDFLAGS)" -o builds/$(BINARY_NAME)-$(VERSION)-linux-amd64 -v
linux_386:
GOOS=linux GOARCH=386 $(GOBUILD) -ldflags="$(LDFLAGS)" -o builds/$(BINARY_NAME)-$(VERSION)-linux-386 -v
linux_arm64:
GOOS=linux GOARCH=arm64 $(GOBUILD) -ldflags="$(LDFLAGS)" -o builds/$(BINARY_NAME)-$(VERSION)-linux-arm64 -v
linux_arm:
GOOS=linux GOARCH=arm GOARM=7 $(GOBUILD) -ldflags="$(LDFLAGS)" -o builds/$(BINARY_NAME)-$(VERSION)-linux-arm -v
windows_amd64:
GOOS=windows GOARCH=amd64 $(GOBUILD) -ldflags="$(LDFLAGS)" -o builds/$(BINARY_NAME)-$(VERSION)-windows-amd64 -v
windows_386:
GOOS=windows GOARCH=386 $(GOBUILD) -ldflags="$(LDFLAGS)" -o builds/$(BINARY_NAME)-$(VERSION)-windows-386 -v
deps:
$(GOGET) ./...
.PHONY: