2019-07-08 20:51:44 +08:00
|
|
|
LAST_COMMIT := $(shell git rev-parse --short HEAD)
|
2020-10-19 01:29:22 +08: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 20:51:44 +08:00
|
|
|
|
2018-10-25 21:51:47 +08:00
|
|
|
BIN := listmonk
|
2020-06-07 02:03:55 +08:00
|
|
|
STATIC := config.toml.sample \
|
|
|
|
schema.sql queries.sql \
|
|
|
|
static/public:/public \
|
|
|
|
static/email-templates \
|
2020-08-09 22:32:43 +08:00
|
|
|
frontend/dist/favicon.png:/frontend/favicon.png \
|
2020-12-19 18:55:52 +08:00
|
|
|
frontend/dist/frontend:/frontend \
|
|
|
|
i18n:/i18n
|
2018-10-25 21:51:47 +08:00
|
|
|
|
2020-10-19 01:14:21 +08:00
|
|
|
# Install dependencies for building.
|
2019-06-26 14:29:03 +08:00
|
|
|
.PHONY: deps
|
|
|
|
deps:
|
|
|
|
go get -u github.com/knadh/stuffbin/...
|
|
|
|
cd frontend && yarn install
|
2019-01-09 19:13:13 +08:00
|
|
|
|
2021-02-20 16:19:14 +08:00
|
|
|
# Run the JS frontend server in dev mode.
|
|
|
|
.PHONY: run-frontend
|
|
|
|
run-frontend:
|
|
|
|
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn serve
|
2019-03-27 16:05:51 +08:00
|
|
|
|
2020-10-19 01:14:21 +08:00
|
|
|
# Build the JS frontend into frontend/dist.
|
|
|
|
.PHONY: build-frontend
|
|
|
|
build-frontend:
|
|
|
|
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn build
|
|
|
|
|
2021-02-20 16:19:14 +08:00
|
|
|
# Run the backend.
|
|
|
|
.PHONY: run
|
|
|
|
run: build
|
|
|
|
./${BIN}
|
2019-07-08 20:51:44 +08:00
|
|
|
|
2021-02-20 16:19:14 +08:00
|
|
|
# Build the backend to ./listmonk.
|
|
|
|
.PHONY: build
|
|
|
|
build:
|
|
|
|
go build -o ${BIN} -ldflags="-s -w -X 'main.buildString=${BUILDSTR}' -X 'main.versionString=${VERSION}'" cmd/*.go
|
2019-07-08 20:51:44 +08:00
|
|
|
|
2020-10-19 01:14:21 +08:00
|
|
|
# pack-releases runns stuffbin packing on the given binary. This is used
|
|
|
|
# in the .goreleaser post-build hook.
|
|
|
|
.PHONY: pack-bin
|
|
|
|
pack-bin:
|
2021-01-24 15:37:42 +08:00
|
|
|
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
|
2020-10-19 01:14:21 +08:00
|
|
|
|
2021-02-20 16:19:14 +08:00
|
|
|
# Bundle all static assets including the JS frontend into the ./listmonk binary
|
|
|
|
# using stuffbin (installed with make deps).
|
|
|
|
.PHONY: dist
|
|
|
|
dist: build build-frontend
|
|
|
|
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}
|
|
|
|
|
2020-10-19 01:14:21 +08: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 21:51:47 +08:00
|
|
|
|
2020-10-19 01:14:21 +08:00
|
|
|
# Use goreleaser to build production releases and publish them.
|
|
|
|
.PHONY: release
|
|
|
|
release:
|
|
|
|
goreleaser --parallelism 1 --rm-dist --skip-validate
|
2021-02-20 16:19:14 +08:00
|
|
|
|
|
|
|
# Opens the cypress frontend tests UI.
|
|
|
|
.PHONY: open-frontend-tests
|
|
|
|
open-frontend-tests:
|
|
|
|
cd frontend && ./node_modules/cypress/bin/cypress open
|
|
|
|
|
|
|
|
# Run Go tests.
|
|
|
|
.PHONY: test
|
|
|
|
test:
|
|
|
|
go test ./...
|