forked from int128/kubelogin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (40 loc) · 1.03 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
PRODUCT := kubelogin
TARGET_ARCHIVE := $(PRODUCT)_$(GOOS)_$(GOARCH).zip
TARGET_DIGEST := $(PRODUCT)_$(GOOS)_$(GOARCH).zip.sha256
ifeq ($(GOOS), windows)
TARGET := $(PRODUCT).exe
else
TARGET := $(PRODUCT)
endif
# 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