listmonk/Makefile

66 lines
1.8 KiB
Makefile
Raw Normal View History

LAST_COMMIT := $(shell git rev-parse --short HEAD)
VERSION := $(shell git describe --tags --abbrev=0)
BUILDSTR := ${VERSION} (\#${LAST_COMMIT} $(shell date -u +"%Y-%m-%dT%H:%M:%S%z"))
2018-10-25 15:51:47 +02:00
BIN := listmonk
STATIC := config.toml.sample \
schema.sql queries.sql \
static/public:/public \
static/email-templates \
frontend/dist/favicon.png:/frontend/favicon.png \
2020-12-19 11:55:52 +01:00
frontend/dist/frontend:/frontend \
i18n:/i18n
2018-10-25 15:51:47 +02:00
# Install dependencies for building.
2019-06-26 08:29:03 +02:00
.PHONY: deps
deps:
go get -u github.com/knadh/stuffbin/...
cd frontend && yarn install
2019-01-09 12:13:13 +01:00
# Build the backend to ./listmonk.
2019-01-09 12:13:13 +01:00
.PHONY: build
2018-10-25 15:51:47 +02:00
build:
go build -o ${BIN} -ldflags="-s -w -X 'main.buildString=${BUILDSTR}' -X 'main.versionString=${VERSION}'" cmd/*.go
2019-06-26 08:29:03 +02:00
# Run the backend.
2019-03-27 09:05:51 +01:00
.PHONY: run
run: build
./${BIN}
# 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 09:53:44 +02:00
.PHONY: run-frontend
run-frontend:
export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn serve
2019-07-02 09:53:44 +02:00
# Run Go tests.
2019-01-09 12:13:13 +01:00
.PHONY: test
2018-10-25 15:51:47 +02:00
test:
go test ./...
# 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}
# 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 08:37:42 +01:00
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 15:51:47 +02:00
# Use goreleaser to build production releases and publish them.
.PHONY: release
release:
goreleaser --parallelism 1 --rm-dist --skip-validate