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})
|
2020-10-02 22:14:13 +00:00
|
|
|
VERSION := $(shell git describe --tags)
|
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
|
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-06-06 18:03:55 +00:00
|
|
|
frontend/dist/frontend:/frontend
|
2018-10-25 13:51:47 +00:00
|
|
|
|
2020-10-18 17:14:21 +00:00
|
|
|
# Install dependencies for building.
|
2019-06-26 06:29:03 +00:00
|
|
|
.PHONY: deps
|
|
|
|
deps:
|
|
|
|
go get -u github.com/knadh/stuffbin/...
|
|
|
|
cd frontend && yarn install
|
2019-01-09 11:13:13 +00:00
|
|
|
|
2020-10-18 17:14:21 +00:00
|
|
|
# Build the backend to ./listmonk.
|
2019-01-09 11:13:13 +00:00
|
|
|
.PHONY: build
|
2018-10-25 13:51:47 +00:00
|
|
|
build:
|
2020-08-08 11:29:47 +00:00
|
|
|
go build -o ${BIN} -ldflags="-s -w -X 'main.buildString=${BUILDSTR}' -X 'main.versionString=${VERSION}'" cmd/*.go
|
2019-06-26 06:29:03 +00:00
|
|
|
|
2020-10-18 17:14:21 +00:00
|
|
|
# Run the backend.
|
2019-03-27 08:05:51 +00:00
|
|
|
.PHONY: run
|
|
|
|
run: build
|
|
|
|
./${BIN}
|
|
|
|
|
2020-10-18 17:14:21 +00:00
|
|
|
# Build the JS frontend into frontend/dist.
|
|
|
|
.PHONY: build-frontend
|
|
|
|
build-frontend:
|
|
|
|
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn build
|
|
|
|
|
|
|
|
# Run the JS frontend server in dev mode.
|
2019-07-02 07:53:44 +00:00
|
|
|
.PHONY: run-frontend
|
|
|
|
run-frontend:
|
2020-06-06 18:03:55 +00:00
|
|
|
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn serve
|
2019-07-02 07:53:44 +00:00
|
|
|
|
2020-10-18 17:14:21 +00:00
|
|
|
# Run Go tests.
|
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 ./...
|
|
|
|
|
2020-10-18 17:14:21 +00:00
|
|
|
# Bundle all static assets including the JS frontend into the ./listmonk binary
|
|
|
|
# using stuffbin (installed with make deps).
|
2019-07-08 12:51:44 +00:00
|
|
|
.PHONY: dist
|
|
|
|
dist: build build-frontend
|
|
|
|
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
|
|
|
|
|
2020-10-18 17:14:21 +00:00
|
|
|
# pack-releases runns stuffbin packing on the given binary. This is used
|
|
|
|
# in the .goreleaser post-build hook.
|
|
|
|
.PHONY: pack-bin
|
|
|
|
pack-bin:
|
|
|
|
stuffbin -a stuff -in $(bin) -out $(bin) ${STATIC}
|
|
|
|
|
|
|
|
# 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
|