From 2305da235998adb16425bf07d407536d025f19c0 Mon Sep 17 00:00:00 2001 From: Martial BE Date: Mon, 25 Mar 2024 11:21:24 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20ci:=20Update=20.gitignore=20and?= =?UTF-8?q?=20add=20makefile=20for=20building=20the=20project?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 ++-- makefile | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 makefile 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