support make file

This commit is contained in:
yanghao05
2023-01-30 10:53:46 +08:00
parent f37666eb7c
commit c7345f6252
3 changed files with 10 additions and 24 deletions

1
.gitignore vendored
View File

@@ -4,3 +4,4 @@ __debug_bin
.idea
tmp/
docker-compose.yml
atom

View File

@@ -1,36 +1,19 @@
buildAt=`date +%Y/%m/%d-%H:%M:%S`
gitHash=`git rev-parse HEAD`
version=`git rev-parse --abbrev-ref HEAD | grep -v HEAD || git describe --exact-match HEAD || git rev-parse HEAD` ## todo: use current release git tag
flags="-X 'app/utils.Version=${version}' -X 'app/utils.BuildAt=${buildAt}' -X 'app/utils.GitHash=${gitHash}'"
flags="-X 'atom/utils.Version=${version}' -X 'atom/utils.BuildAt=${buildAt}' -X 'atom/utils.GitHash=${gitHash}'"
GOPATH:=$(shell go env GOPATH)
.PHONY: init
init:
@go get -u google.golang.org/protobuf/proto
@go install github.com/golang/protobuf/protoc-gen-go@latest
@go install github.com/go-micro/generator/cmd/protoc-gen-micro@latest
.PHONY: proto
proto:
@protoc --proto_path=. --micro_out=. --go_out=:. proto/web_api.proto
.PHONY: update
update:
@go get -u
.PHONY: tidy
tidy:
@go mod tidy
.PHONY: build
build:
@go build -ldflags=${flags}
.PHONY: dist
dist:
@go build -ldflags=${flags} -o bin/atom
@cp config.toml bin/
.PHONY: test
test:
@go test -v ./... -cover
.PHONY: docker
docker:
@docker build -t web_api:latest .

2
bin/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore