diff --git a/.goreleaser.yml b/.goreleaser.yml index 55d3bc0..99b30a7 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,7 +1,6 @@ env: - GO111MODULE=on - CGO_ENABLED=0 - - RELEASE_BUILDS=dist/listmonk_darwin_amd64/listmonk dist/listmonk_linux_amd64/listmonk dist/listmonk_windows_amd64/listmonk.exe before: hooks: @@ -21,7 +20,7 @@ builds: hooks: # stuff executables with static assets. - post: make pack-releases + post: make pack-bin bin={{ .Path }} archives: - format: tar.gz diff --git a/Makefile b/Makefile index 856173f..29e97bc 100644 --- a/Makefile +++ b/Makefile @@ -11,43 +11,55 @@ STATIC := config.toml.sample \ frontend/dist/favicon.png:/frontend/favicon.png \ frontend/dist/frontend:/frontend -# Dependencies. +# Install dependencies for building. .PHONY: deps deps: go get -u github.com/knadh/stuffbin/... cd frontend && yarn install -# Build steps. +# 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 -.PHONY: build-frontend -build-frontend: - export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn build - +# Run the backend. .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. .PHONY: run-frontend run-frontend: export VUE_APP_VERSION="${VERSION}" && cd frontend && yarn serve +# Run Go tests. .PHONY: test test: go test ./... -# dist builds the backend, frontend, and uses stuffbin to -# embed all frontend assets into the binary. +# 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 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};) +# 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 + +# Use goreleaser to build production releases and publish them. +.PHONY: release +release: + goreleaser --parallelism 1 --rm-dist --skip-validate