2019-07-08 12:51:44 +00:00
|
|
|
LAST_COMMIT := $(shell git rev-parse --short HEAD)
|
2020-10-18 17:29:22 +00:00
|
|
|
VERSION := $(shell git describe --tags --abbrev=0)
|
|
|
|
BUILDSTR := ${VERSION} (\#${LAST_COMMIT} $(shell date -u +"%Y-%m-%dT%H:%M:%S%z"))
|
2019-07-08 12:51:44 +00:00
|
|
|
|
2021-06-26 17:20:40 +00:00
|
|
|
YARN ?= yarn
|
2021-06-26 18:25:02 +00:00
|
|
|
GOPATH ?= $(HOME)/go
|
|
|
|
STUFFBIN ?= $(GOPATH)/bin/stuffbin
|
|
|
|
FRONTEND_YARN_MODULES = frontend/node_modules
|
|
|
|
FRONTEND_DIST = frontend/dist
|
|
|
|
FRONTEND_DEPS = \
|
|
|
|
$(FRONTEND_YARN_MODULES) \
|
|
|
|
frontend/package.json \
|
|
|
|
frontend/vue.config.js \
|
|
|
|
frontend/babel.config.js \
|
|
|
|
$(shell find frontend/fontello frontend/public frontend/src -type f)
|
2021-06-26 17:20:40 +00:00
|
|
|
|
2018-10-25 13:51:47 +00:00
|
|
|
BIN := listmonk
|
2020-06-06 18:03:55 +00:00
|
|
|
STATIC := config.toml.sample \
|
|
|
|
schema.sql queries.sql \
|
|
|
|
static/public:/public \
|
|
|
|
static/email-templates \
|
2020-08-09 14:32:43 +00:00
|
|
|
frontend/dist/favicon.png:/frontend/favicon.png \
|
2020-12-19 10:55:52 +00:00
|
|
|
frontend/dist/frontend:/frontend \
|
|
|
|
i18n:/i18n
|
2018-10-25 13:51:47 +00:00
|
|
|
|
2021-06-26 18:25:02 +00:00
|
|
|
.PHONY: build
|
|
|
|
build: $(BIN)
|
|
|
|
|
|
|
|
$(STUFFBIN):
|
2019-06-26 06:29:03 +00:00
|
|
|
go get -u github.com/knadh/stuffbin/...
|
2021-06-26 18:25:02 +00:00
|
|
|
|
|
|
|
$(FRONTEND_YARN_MODULES): frontend/package.json frontend/yarn.lock
|
2021-06-26 17:20:40 +00:00
|
|
|
cd frontend && $(YARN) install
|
2021-06-26 18:25:02 +00:00
|
|
|
touch --no-create $(FRONTEND_YARN_MODULES)
|
2019-01-09 11:13:13 +00:00
|
|
|
|
2021-04-11 07:26:56 +00:00
|
|
|
# Build the backend to ./listmonk.
|
2021-06-26 18:25:02 +00:00
|
|
|
$(BIN): $(shell find cmd -type f -name "*.go")
|
2021-04-11 07:26:56 +00:00
|
|
|
CGO_ENABLED=0 go build -o ${BIN} -ldflags="-s -w -X 'main.buildString=${BUILDSTR}' -X 'main.versionString=${VERSION}'" cmd/*.go
|
2020-10-18 17:14:21 +00:00
|
|
|
|
2021-02-20 08:19:14 +00:00
|
|
|
# Run the backend.
|
|
|
|
.PHONY: run
|
2021-06-26 18:25:02 +00:00
|
|
|
run: $(BIN)
|
2021-02-20 08:19:14 +00:00
|
|
|
./${BIN}
|
2019-07-08 12:51:44 +00:00
|
|
|
|
2021-04-11 07:26:56 +00:00
|
|
|
# Build the JS frontend into frontend/dist.
|
2021-06-26 18:25:02 +00:00
|
|
|
$(FRONTEND_DIST): $(FRONTEND_DEPS)
|
2021-06-26 17:20:40 +00:00
|
|
|
export VUE_APP_VERSION="${VERSION}" && cd frontend && $(YARN) build
|
2021-06-26 18:25:02 +00:00
|
|
|
touch --no-create $(FRONTEND_DIST)
|
|
|
|
|
|
|
|
.PHONY: build-frontend
|
|
|
|
build-frontend: $(FRONTEND_DIST)
|
2019-07-08 12:51:44 +00:00
|
|
|
|
2021-04-11 07:26:56 +00:00
|
|
|
# Run the JS frontend server in dev mode.
|
|
|
|
.PHONY: run-frontend
|
|
|
|
run-frontend:
|
2021-06-26 17:20:40 +00:00
|
|
|
export VUE_APP_VERSION="${VERSION}" && cd frontend && $(YARN) serve
|
2021-04-11 07:26:56 +00:00
|
|
|
|
|
|
|
# Run Go tests.
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
|
|
|
go test ./...
|
2020-10-18 17:14:21 +00:00
|
|
|
|
2021-02-20 08:19:14 +00:00
|
|
|
# Bundle all static assets including the JS frontend into the ./listmonk binary
|
|
|
|
# using stuffbin (installed with make deps).
|
|
|
|
.PHONY: dist
|
2021-06-26 18:25:02 +00:00
|
|
|
dist: $(STUFFBIN) build build-frontend
|
|
|
|
$(STUFFBIN) -a stuff -in ${BIN} -out ${BIN} ${STATIC}
|
2021-02-20 08:19:14 +00:00
|
|
|
|
2021-04-11 07:26:56 +00:00
|
|
|
# pack-releases runns stuffbin packing on the given binary. This is used
|
|
|
|
# in the .goreleaser post-build hook.
|
|
|
|
.PHONY: pack-bin
|
2021-06-26 18:25:02 +00:00
|
|
|
pack-bin: $(STUFFBIN)
|
|
|
|
$(STUFFBIN) -a stuff -in ${BIN} -out ${BIN} ${STATIC}
|
2021-04-11 07:26:56 +00:00
|
|
|
|
2020-10-18 17:14:21 +00:00
|
|
|
# Use goreleaser to do a dry run producing local builds.
|
|
|
|
.PHONY: release-dry
|
|
|
|
release-dry:
|
|
|
|
goreleaser --parallelism 1 --rm-dist --snapshot --skip-validate --skip-publish
|
2018-10-25 13:51:47 +00:00
|
|
|
|
2020-10-18 17:14:21 +00:00
|
|
|
# Use goreleaser to build production releases and publish them.
|
|
|
|
.PHONY: release
|
|
|
|
release:
|
|
|
|
goreleaser --parallelism 1 --rm-dist --skip-validate
|