forked from gravitational/teleport-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (44 loc) · 1.25 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
VERSION=0.2.0
BUILDDIR ?= build
BINARY = $(BUILDDIR)/teleport-slack
GITTAG=v$(VERSION)
ADDFLAGS ?=
BUILDFLAGS ?= $(ADDFLAGS) -ldflags '-w -s'
CGOFLAG ?= CGO_ENABLED=1
OS ?= $(shell go env GOOS)
ARCH ?= $(shell go env GOARCH)
RELEASE_NAME=teleport-access-slack
RELEASE=$(RELEASE_NAME)-$(GITTAG)-$(OS)-$(ARCH)-bin
RELEASE_MESSAGE := "Building with GOOS=$(OS) GOARCH=$(ARCH)."
VERSRC = version.go gitref.go
export
.PHONY: $(BINARY)
$(BINARY):
GOOS=$(OS) GOARCH=$(ARCH) $(CGOFLAG) go build -o $(BINARY) $(BUILDFLAGS)
.PHONY: test
test: FLAGS ?= '-race'
test: $(VERSRC)
GOOS=$(OS) GOARCH=$(ARCH) $(CGOFLAG) go test $(FLAGS) $(ADDFLAGS)
clean:
@echo "---> Cleaning up build artifacts."
rm -rf $(BUILDDIR)
-go clean -cache
rm -rf $(RELEASE_NAME)
rm -rf *.gz
rm -f gitref.go
.PHONY: release
release: clean $(VERSRC) $(BINARY)
@echo "---> $(RELEASE_MESSAGE)"
mkdir $(RELEASE_NAME)
cp -rf $(BINARY) \
README.md \
CHANGELOG.md \
install \
$(RELEASE_NAME)/
echo $(GITTAG) > $(RELEASE_NAME)/VERSION
tar -czf $(RELEASE).tar.gz $(RELEASE_NAME)
rm -rf $(RELEASE_NAME)/
@echo "---> Created $(RELEASE).tar.gz."
# This rule triggers re-generation of version.go and gitref.go if Makefile changes
$(VERSRC): Makefile
VERSION=$(VERSION) $(MAKE) -f version.mk setver