2019-07-08 12:51:44 +00:00
|
|
|
LAST_COMMIT := $(shell git rev-parse --short HEAD)
|
|
|
|
LAST_COMMIT_DATE := $(shell git show -s --format=%ci ${LAST_COMMIT})
|
2019-09-06 08:02:07 +00:00
|
|
|
VERSION := $(shell git describe)
|
2019-09-06 08:13:49 +00:00
|
|
|
BUILDSTR := ${VERSION} (${LAST_COMMIT} $(shell date -u +"%Y-%m-%dT%H:%M:%S%z"))
|
2019-07-08 12:51:44 +00:00
|
|
|
|
2018-10-25 13:51:47 +00:00
|
|
|
BIN := listmonk
|
2019-05-27 11:47:26 +00:00
|
|
|
STATIC := config.toml.sample schema.sql queries.sql public email-templates frontend/build:/frontend
|
2018-10-25 13:51:47 +00:00
|
|
|
|
2019-06-26 06:29:03 +00:00
|
|
|
# Dependencies.
|
|
|
|
.PHONY: deps
|
|
|
|
deps:
|
|
|
|
go get -u github.com/knadh/stuffbin/...
|
|
|
|
cd frontend && yarn install
|
2019-01-09 11:13:13 +00:00
|
|
|
|
2019-06-26 06:29:03 +00:00
|
|
|
# Build steps.
|
2019-01-09 11:13:13 +00:00
|
|
|
.PHONY: build
|
2018-10-25 13:51:47 +00:00
|
|
|
build:
|
2019-07-08 12:51:44 +00:00
|
|
|
go build -o ${BIN} -ldflags="-s -w -X 'main.buildString=${BUILDSTR}'"
|
2019-06-26 06:29:03 +00:00
|
|
|
|
|
|
|
.PHONY: build-frontend
|
|
|
|
build-frontend:
|
|
|
|
cd frontend && yarn build
|
|
|
|
|
2019-03-27 08:05:51 +00:00
|
|
|
.PHONY: run
|
|
|
|
run: build
|
|
|
|
./${BIN}
|
|
|
|
|
2019-07-02 07:53:44 +00:00
|
|
|
.PHONY: run-frontend
|
|
|
|
run-frontend:
|
|
|
|
cd frontend && yarn start
|
|
|
|
|
2019-01-09 11:13:13 +00:00
|
|
|
.PHONY: test
|
2018-10-25 13:51:47 +00:00
|
|
|
test:
|
2019-07-08 12:51:44 +00:00
|
|
|
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} $(var);)
|
2018-10-25 13:51:47 +00:00
|
|
|
|