-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
54 lines (42 loc) · 1.09 KB
/
Copy pathMakefile
File metadata and controls
54 lines (42 loc) · 1.09 KB
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
BIN := yd
VERSION := $$(make -s show-version)
VERSION_PATH := .
CURRENT_REVISION := $(shell git rev-parse --short HEAD)
BUILD_LDFLAGS := "-s -w -X github.com/starrychasu/yd/cmd.Revision=$(CURRENT_REVISION)"
GOBIN ?= $(shell go env GOPATH)/bin
export GO111MODULE=on
.PHONY: init
init:
ifeq ($(shell uname -s),Darwin)
@grep -r -l yd * | xargs sed -i "" "s/yid/$$(basename `git rev-parse --show-toplevel`)/"
else
@grep -r -l yd * | xargs sed -i "s/yid/$$(basename `git rev-parse --show-toplevel`)/"
endif
.PHONY: all
all: clean build
.PHONY: build
build:
go build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) .
.PHONY: install
install:
go install -ldflags=$(BUILD_LDFLAGS) ./...
.PHONY: show-version
show-version:
@git describe --tags --abbrev=0
.PHONY: cross
cross: $(GOBIN)/goxz
goxz -n $(BIN) -pv=$(VERSION) -build-ldflags=$(BUILD_LDFLAGS) .
$(GOBIN)/goxz:
cd && go get github.com/Songmu/goxz/cmd/goxz
.PHONY: test
test: build
go test -v ./...
.PHONY: clean
clean:
rm -rf $(BIN) goxz
go clean
.PHONY: upload
upload: $(GOBIN)/ghr
ghr "$(VERSION)" goxz
$(GOBIN)/ghr:
cd && go get github.com/tcnksm/ghr