Refactor Makefile
This commit is contained in:
parent
4f9bb269a3
commit
95038d3f3c
56
Makefile
56
Makefile
|
@ -6,59 +6,29 @@ COMMIT_DATE := $(shell git show -s --format=%ci ${HASH})
|
||||||
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')
|
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')
|
||||||
VERSION := ${HASH} (${COMMIT_DATE})
|
VERSION := ${HASH} (${COMMIT_DATE})
|
||||||
|
|
||||||
.PHONY: build-frontend
|
# Dependencies.
|
||||||
build-frontend:
|
.PHONY: deps
|
||||||
cd frontend && yarn install && yarn build
|
deps:
|
||||||
|
go get -u github.com/knadh/stuffbin/...
|
||||||
.PHONY: quickdev
|
cd frontend && yarn install
|
||||||
quickdev:
|
|
||||||
@ if [ ! -d "frontend/node_modules" ]; then \
|
|
||||||
echo "Installing frontend deps"; \
|
|
||||||
cd frontend && yarn install; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
@ if [ ! -d "frontend/build" ]; then \
|
|
||||||
echo "Creating build directory"; \
|
|
||||||
mkdir -p frontend/build; \
|
|
||||||
echo "Building frontend assets"; \
|
|
||||||
cd frontend && yarn build; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
@ echo -e "\nBuilding go binary\n"
|
|
||||||
make build
|
|
||||||
|
|
||||||
@ echo -e "Editing database params inside config\n"
|
|
||||||
cp config.toml.sample config.toml
|
|
||||||
|
|
||||||
@ echo -n "Database user: "
|
|
||||||
@ read DBUSER; \
|
|
||||||
sed -i -e "s/user = \"listmonk\"/user = \"$${DBUSER}\"/g" config.toml
|
|
||||||
|
|
||||||
@ echo -n "Database password: "
|
|
||||||
@ read DBPASSWORD; \
|
|
||||||
sed -i -e "s/password = \"\"/password = \"$${DBPASSWORD}\"/g" config.toml
|
|
||||||
|
|
||||||
@ echo -n "Database name: "
|
|
||||||
@ read DBNAME; \
|
|
||||||
sed -i -e "s/database = \"listmonk\"/database = \"$${DBNAME}\"/g" config.toml; \
|
|
||||||
createdb $${DBNAME}
|
|
||||||
|
|
||||||
@ echo -e "Running installer\n"
|
|
||||||
./listmonk --install
|
|
||||||
|
|
||||||
|
# Build steps.
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build:
|
build:
|
||||||
go build -o ${BIN} -ldflags="-s -w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'"
|
go build -o ${BIN} -ldflags="-s -w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'"
|
||||||
|
|
||||||
|
.PHONY: build-frontend
|
||||||
|
build-frontend:
|
||||||
|
cd frontend && yarn build
|
||||||
|
|
||||||
|
.PHONY: build-dist
|
||||||
|
build-dist:
|
||||||
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
|
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: build
|
run: build
|
||||||
./${BIN}
|
./${BIN}
|
||||||
|
|
||||||
.PHONY: deps
|
|
||||||
deps:
|
|
||||||
go get -u github.com/knadh/stuffbin/...
|
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
go test
|
go test
|
||||||
|
|
Loading…
Reference in New Issue