diff --git a/.gitignore b/.gitignore index c84fb556..9a275649 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,6 @@ data tmp/ /test/ .env -common/plugin/ common/balancer/ -config.yaml \ No newline at end of file +config.yaml +dist \ No newline at end of file diff --git a/makefile b/makefile new file mode 100644 index 00000000..b8371f67 --- /dev/null +++ b/makefile @@ -0,0 +1,18 @@ +NAME=one-api +DISTDIR=dist +WEBDIR=web +VERSION=$(shell git describe --tags || echo "dev") +GOBUILD=go build -ldflags "-s -w -X 'one-api/common.Version=$(VERSION)'" + +all: one-api + +web: $(WEBDIR)/build + +$(WEBDIR)/build: + cd $(WEBDIR) && npm install && REACT_APP_VERSION=$(VERSION) npm run build + +one-api: web + $(GOBUILD) -o $(DISTDIR)/$(NAME) + +clean: + rm -rf $(DISTDIR) && rm -rf $(WEBDIR)/build \ No newline at end of file