listmonk/Makefile

54 lines
1.4 KiB
Makefile
Raw Normal View History

LAST_COMMIT := $(shell git rev-parse --short HEAD)
LAST_COMMIT_DATE := $(shell git show -s --format=%ci ${LAST_COMMIT})
2019-09-06 16:02:07 +08:00
VERSION := $(shell git describe)
BUILDSTR := ${VERSION} (${LAST_COMMIT} $(shell date -u +"%Y-%m-%dT%H:%M:%S%z"))
2018-10-25 21:51:47 +08:00
BIN := listmonk
STATIC := config.toml.sample \
schema.sql queries.sql \
static/public:/public \
static/email-templates \
frontend/dist/favicon.png:/frontend/favicon.png \
frontend/dist/frontend:/frontend
2018-10-25 21:51:47 +08:00
2019-06-26 14:29:03 +08:00
# Dependencies.
.PHONY: deps
deps:
go get -u github.com/knadh/stuffbin/...
cd frontend && yarn install
2019-01-09 19:13:13 +08:00
2019-06-26 14:29:03 +08:00
# Build steps.
2019-01-09 19:13:13 +08:00
.PHONY: build
2018-10-25 21:51:47 +08:00
build:
go build -o ${BIN} -ldflags="-s -w -X 'main.buildString=${BUILDSTR}' -X 'main.versionString=${VERSION}'" cmd/*.go
2019-06-26 14:29:03 +08:00
.PHONY: build-frontend
build-frontend:
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn build
2019-06-26 14:29:03 +08:00
2019-03-27 16:05:51 +08:00
.PHONY: run
run: build
./${BIN}
2019-07-02 15:53:44 +08:00
.PHONY: run-frontend
run-frontend:
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn serve
2019-07-02 15:53:44 +08:00
2019-01-09 19:13:13 +08:00
.PHONY: test
2018-10-25 21:51:47 +08:00
test:
go test ./...
# dist builds the backend, frontend, and uses stuffbin to
# embed all frontend assets into the binary.
.PHONY: dist
dist: build build-frontend
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
# pack-releases runns stuffbin packing on a given list of
# binaries. This is used with goreleaser for packing
# release builds for cross-build targets.
.PHONY: pack-releases
pack-releases:
$(foreach var,$(RELEASE_BUILDS),stuffbin -a stuff -in ${var} -out ${var} ${STATIC};)
2018-10-25 21:51:47 +08:00