Skip to content

Commit

Permalink
Refactor and add new build routines
Browse files Browse the repository at this point in the history
- Fix version injection in build
- Refactor Makefile
- Add --new-config flag to generate sample config
- Add license
- Remove autogenerated frontend README
- Refactor make dist to do end-to-end build
- Refactor build and add goreleaser conf
  • Loading branch information
knadh committed Jul 9, 2019
1 parent 0e116a2 commit e89a54b
Show file tree
Hide file tree
Showing 7 changed files with 759 additions and 2,470 deletions.
29 changes: 29 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
env:
- GO111MODULE=on
- RELEASE_BUILDS=dist/listmonk_darwin_amd64/listmonk dist/listmonk_linux_amd64/listmonk dist/listmonk_windows_amd64//listmonk.exe

before:
hooks:
- make build-frontend

builds:
- binary: listmonk
goos:
- windows
- darwin
- linux
goarch:
- amd64
ldflags:
- -s -w -X "main.buildString={{ .Tag }} ({{ .ShortCommit }} {{ .Date }})"

hooks:
# stuff executables with static assets.
post: make pack-releases

archives:
- format: tar.gz
files:
- config.toml.sample
- README.md
- LICENSE
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

35 changes: 20 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
LAST_COMMIT := $(shell git rev-parse --short HEAD)
LAST_COMMIT_DATE := $(shell git show -s --format=%ci ${LAST_COMMIT})
VERSION := $(shell git tag)
BUILDSTR := ${VERSION} (${LAST_COMMIT} $(shell date -u +"%Y-%m-%dT%H:%M:%SZ"))

BIN := listmonk
STATIC := config.toml.sample schema.sql queries.sql public email-templates frontend/build:/frontend

HASH := $(shell git rev-parse --short HEAD)
COMMIT_DATE := $(shell git show -s --format=%ci ${HASH})
BUILD_DATE := $(shell date '+%Y-%m-%d %H:%M:%S')
VERSION := ${HASH} (${COMMIT_DATE})

# Dependencies.
.PHONY: deps
deps:
Expand All @@ -15,16 +15,12 @@ deps:
# Build steps.
.PHONY: build
build:
go build -o ${BIN} -ldflags="-s -w -X 'main.buildVersion=${VERSION}' -X 'main.buildDate=${BUILD_DATE}'"
go build -o ${BIN} -ldflags="-s -w -X 'main.buildString=${BUILDSTR}'"

.PHONY: build-frontend
build-frontend:
cd frontend && yarn build

.PHONY: dist
build-dist:
stuffbin -a stuff -in ${BIN} -out ${BIN} ${STATIC}

.PHONY: run
run: build
./${BIN}
Expand All @@ -35,9 +31,18 @@ run-frontend:

.PHONY: test
test:
go test
go test ./...

# dist builds the backend, frontend, and uses stuffbin to
# embed all frontend assets into the binary.
.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} $(var);)

.PHONY: clean
clean:
go clean
- rm -f ${BIN}
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ listmonk is a standalone newsletter and mailing list manager written in Go. It i
### Installation and use

- Download the [latest release](https://github.com/knadh/listmonk/releases) and extract the listmonk binary somewhere.
- Copy `config.toml.sample` to `config.toml` and add your configuration (SMTP and Postgres DB credentials primarily).
- Run `./listmonk --new-config` to generate a sample `config.toml` and add your configuration (SMTP and Postgres DB credentials primarily).
- `./listmonk --install` to setup the DB.
- Visit `http://localhost:9000`.
- Since there is no user auth yet, it's best to put listmonk behind a proxy like Nginx and setup basicauth on all endpoints except for the few endpoints that need to be public. Here is a [sample nginx config](https://github.com/knadh/listmonk/wiki/Production-Nginx-config) for production use.
Expand Down Expand Up @@ -43,3 +43,7 @@ listmonk is a standalone newsletter and mailing list manager written in Go. It i
listmonk is free, open source software licensed under AGPLv3. There are a few of essential features such as user auth/management and bounce tracking that are currently missing. Contributions are welcome.

The backend is written in Go and the frontend is in React with Ant Design for UI. See [developer setup](https://github.com/knadh/listmonk/wiki/Developer-setup) to get started.

## License

listmonk is licensed under the AGPL v3 license.
Loading

0 comments on commit e89a54b

Please sign in to comment.