listmonk/Makefile

70 lines
1.6 KiB
Makefile
Raw Normal View History

2018-10-25 15:51:47 +02:00
BIN := listmonk
STATIC := config.toml.sample schema.sql queries.sql public email-templates frontend/my/build:/frontend
2018-10-25 15:51:47 +02:00
HASH := $(shell git rev-parse --short HEAD)
COMMIT_DATE := $(shell git show -s --format=%ci ${HASH})
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')
VERSION := ${HASH} (${COMMIT_DATE})
2019-01-09 12:13:13 +01:00
.PHONY: build_frontend
build_frontend:
cd frontend/my && yarn install && yarn build
.PHONY: quickdev
quickdev:
@ if [ ! -d "frontend/my/node_modules" ]; then \
echo "Installing frontend deps"; \
cd frontend/my && yarn install; \
fi
@ if [ ! -d "frontend/my/build" ]; then \
echo "Creating build directory"; \
mkdir -p frontend/my/build; \
echo "Building frontend assets"; \
cd frontend/my && 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
.PHONY: build
2018-10-25 15:51:47 +02:00
build:
go build -o ${BIN} -ldflags="-s -w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'"
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
2019-03-27 09:05:51 +01:00
.PHONY: run
run: build
./${BIN}
2019-01-09 12:13:13 +01:00
.PHONY: deps
deps:
go get -u github.com/knadh/stuffbin/...
2018-10-25 15:51:47 +02:00
2019-01-09 12:13:13 +01:00
.PHONY: test
2018-10-25 15:51:47 +02:00
test:
go test
2019-01-09 12:13:13 +01:00
.PHONY: clean
2018-10-25 15:51:47 +02:00
clean:
go clean
- rm -f ${BIN}