This repository has been archived by the owner on Apr 30, 2020. It is now read-only.
forked from micahhausler/k8s-oidc-helper
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
78 lines (57 loc) · 2.34 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
78
SHELL := /bin/bash
GITHUB_OWNER = moia-dev
GITHUB_REPOSITORY = k8s-oidc-helper
# The destination for binaries
BUILD_DIR = build
# The name of the executable (default is current directory name)
TARGET := $(shell echo $${PWD\#\#*/})
.DEFAULT_GOAL: $(TARGET)
# These will be provided to the target
VERSION :=0.2.0
BUILD := `git rev-parse HEAD`
# Use linker flags to provide version/build settings to the target
LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)"
# go source files, ignore vendor directory
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
.PHONY: all build clean install uninstall fmt simplify check run
all: check compile
$(TARGET): $(SRC)
@go build $(LDFLAGS) -o $(TARGET)
.PHONY: release
release: guard-VERSION guard-GITHUB_TOKEN compile
github-release info --user $(GITHUB_OWNER) --repo $(GITHUB_REPOSITORY)
github-release release --user $(GITHUB_OWNER) --repo $(GITHUB_REPOSITORY) --tag v$(VERSION) --name v$(VERSION)
cd build && zip -r linux linux && github-release upload --user $(GITHUB_OWNER) --repo $(GITHUB_REPOSITORY) --tag v$(VERSION) --name linux.zip --file linux.zip;
cd build && zip -r darwin darwin && github-release upload --user $(GITHUB_OWNER) --repo $(GITHUB_REPOSITORY) --tag v$(VERSION) --name darwin.zip --file darwin.zip;
github-release edit --user $(GITHUB_OWNER) --repo $(GITHUB_REPOSITORY) --tag v$(VERSION) --name v$(VERSION) --description v$(VERSION)
compile: check goxcompile
goxcompile: export CGO_ENABLED=0
goxcompile: dependencies
gox -arch amd64 -os darwin -os linux -os windows -output "$(BUILD_DIR)/{{.OS}}/$(NAME)/${TARGET}" .
clean:
@rm -f $(TARGET)
@rm -rf $(BUILD_DIR)
install: dependencies
@go install $(LDFLAGS)
uninstall: clean
@rm -f $$(which ${TARGET})
fmt:
@gofmt -l -w $(SRC)
simplify:
@gofmt -s -l -w $(SRC)
check: dependencies
@test -z $(shell gofmt -l *.go | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make fmt'"
@for d in $$(go list ./... | grep -v /vendor/); do golint $${d}; done
@go tool vet ${SRC}
run: install
@$(TARGET)
dependencies:
go get github.com/mitchellh/gox
go get github.com/jstemmer/go-junit-report
go get github.com/golang/lint/golint
git submodule update --init --recursive
guard-%:
@ if [ "${${*}}" = "" ]; then \
echo "Environment variable $* not set"; \
exit 1; \
fi