forked from int128/kubelogin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
43 lines (35 loc) · 963 Bytes
/
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
TARGET := kubelogin
TARGET_ARCHIVE := $(TARGET)_$(GOOS)_$(GOARCH).zip
TARGET_DIGEST := $(TARGET)_$(GOOS)_$(GOARCH).zip.sha256
# determine the version from ref
ifeq ($(GITHUB_REF), refs/heads/master)
VERSION := latest
else
VERSION ?= $(notdir $(GITHUB_REF))
endif
LDFLAGS := -X main.version=$(VERSION)
all: $(TARGET)
$(TARGET):
go build -o $@ -ldflags "$(LDFLAGS)"
.PHONY: dist
dist: $(TARGET_ARCHIVE) $(TARGET_DIGEST)
$(TARGET_ARCHIVE): $(TARGET)
ifeq ($(GOOS), windows)
powershell Compress-Archive -Path $(TARGET),LICENSE,README.md -DestinationPath $@
else
zip $@ $(TARGET) LICENSE README.md
endif
$(TARGET_DIGEST): $(TARGET_ARCHIVE)
ifeq ($(GOOS), darwin)
shasum -a 256 -b $(TARGET_ARCHIVE) > $@
else
sha256sum -b $(TARGET_ARCHIVE) > $@
endif
.PHONY: dist-release
dist-release: dist
gh release upload $(VERSION) $(TARGET_ARCHIVE) $(TARGET_DIGEST) --clobber
.PHONY: clean
clean:
-rm $(TARGET)
-rm -r dist/output/
-rm coverage.out gotest.log