-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
65 lines (50 loc) · 1.5 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
.PHONY: test build
# This can be changed by exporting an env variable
XGO_TARGETS ?= linux/amd64,windows/amd64,darwin/amd64
GOBIN = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))build/bin
PROJECT_NAME=keycard-cli
BIN_NAME=keycard
VERSION = $(shell cat VERSION)
export GITHUB_USER ?= status-im
export GITHUB_REPO ?= $(PROJECT_NAME)
export IMAGE_TAG ?= xgo-1.18.1
export IMAGE_NAME ?= statusteam/keycard-cli-ci:$(IMAGE_TAG)
export GO_PROJECT_PATH ?= github.com/$(GITHUB_USER)/$(GITHUB_REPO)
deps: install-xgo install-github-release
go version
install-xgo:
go install github.com/crazy-max/xgo@v0.23.0
install-github-release:
go install github.com/aktau/github-release@v0.10.0
build:
go build -o $(GOBIN)/$(BIN_NAME) -v -ldflags "-X main.version=$(VERSION)" .
@echo "Compilation done."
@echo "Run \"./build/bin/$(BIN_NAME)\" to view available commands."
test:
go test -v ./...
docker-image:
cd _assets/docker && $(MAKE) push
build-platforms:
xgo \
-ldflags="-X main.version=$(VERSION)" \
-out=$(BIN_NAME) \
-dest=$(GOBIN) \
-docker-image=$(IMAGE_NAME) \
-targets=$(XGO_TARGETS) .
release:
ifndef GITHUB_TOKEN
$(error GITHUB_TOKEN is not set. Unable to release to GitHub.)
endif
# FIXME: this might remove a real release if not careful
-github-release delete --tag $(VERSION)
github-release release --tag $(VERSION) --draft
cd $(GOBIN); \
for FILE in $$(ls); do \
github-release upload \
--tag $(VERSION) \
--file $${FILE} \
--name $${FILE} \
--replace; \
done
clean:
rm -f $(GOBIN)/*