-
Notifications
You must be signed in to change notification settings - Fork 69
/
Makefile
55 lines (46 loc) · 1.15 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
BIN := sqls
ifeq ($(OS),Windows_NT)
BIN := $(BIN).exe
endif
VERSION := $$(make -s show-version)
CURRENT_REVISION := $(shell git rev-parse --short HEAD)
BUILD_LDFLAGS := "-s -w -X main.revision=$(CURRENT_REVISION)"
GOOS := $(shell go env GOOS)
GOBIN ?= $(shell go env GOPATH)/bin
export GO111MODULE=on
.PHONY: all
all: clean build
.PHONY: build
build:
go build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) .
.PHONY: release
release:
go build -ldflags=$(BUILD_LDFLAGS) -o $(BIN) .
zip -r sqls-$(GOOS)-$(VERSION).zip $(BIN)
.PHONY: install
install:
go install -ldflags=$(BUILD_LDFLAGS) .
.PHONY: show-version
show-version: $(GOBIN)/gobump
gobump show -r .
$(GOBIN)/gobump:
go install github.com/x-motemen/gobump/cmd/gobump@latest
.PHONY: test
test: build
go test -v ./...
.PHONY: clean
clean:
go clean
.PHONY: bump
bump: $(GOBIN)/gobump
ifneq ($(shell git status --porcelain),)
$(error git workspace is dirty)
endif
ifneq ($(shell git rev-parse --abbrev-ref HEAD),master)
$(error current branch is not master)
endif
@gobump up -w .
git commit -am "bump up version to $(VERSION)"
git tag "v$(VERSION)"
git push origin master
git push origin "refs/tags/v$(VERSION)"