-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
67 lines (56 loc) · 2.56 KB
/
Copy pathMakefile
File metadata and controls
67 lines (56 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
VERSION := $(shell git describe --tags --always 2>/dev/null || echo dev)
LDFLAGS := -s -w -X main.version=$(VERSION)
BIN := dist/csat
PKG := csat-$(VERSION)-linux-amd64
.PHONY: build build-linux package package-customer run test vet fmt tidy clean
build:
go build -trimpath -ldflags="$(LDFLAGS)" -o $(BIN) ./cmd/csat
# Single static Linux/amd64 binary (pure-Go sqlite => no cgo needed).
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
go build -trimpath -ldflags="$(LDFLAGS)" -o $(BIN)-linux-amd64 ./cmd/csat
# Release bundle: the single static binary + config templates + systemd unit +
# installer + docs, as one tarball for delivery.
package: build-linux
rm -rf dist/$(PKG)
mkdir -p dist/$(PKG)
cp dist/csat-linux-amd64 dist/$(PKG)/csat
cp config.example.toml .env.example survey.example.json INSTALL.md README.md LICENSE NOTICE dist/$(PKG)/
cp deploy/csat.service deploy/install.sh deploy/update.sh deploy/csat-update.service deploy/csat-update.timer dist/$(PKG)/
cp deploy/nginx-csat.conf.example deploy/apache-csat.conf.example dist/$(PKG)/
chmod +x dist/$(PKG)/csat dist/$(PKG)/install.sh dist/$(PKG)/update.sh
tar -C dist -czf dist/$(PKG).tar.gz $(PKG)
@echo "packaged: dist/$(PKG).tar.gz"
@ls -lh dist/$(PKG).tar.gz
# Per-customer bundle: same static binary + that customer's config.toml, csat.env,
# and logo (from customers/<name>/), ready to unpack + ./install.sh on their host.
# make package-customer CUSTOMER=curacao
package-customer: build-linux
@test -n "$(CUSTOMER)" || { echo "usage: make package-customer CUSTOMER=<name>"; exit 1; }
@test -f customers/$(CUSTOMER)/config.toml || { echo "missing customers/$(CUSTOMER)/config.toml"; exit 1; }
$(eval OUT := csat-$(CUSTOMER)-linux-amd64)
rm -rf dist/$(OUT)
mkdir -p dist/$(OUT)
cp dist/csat-linux-amd64 dist/$(OUT)/csat
cp customers/$(CUSTOMER)/config.toml customers/$(CUSTOMER)/csat.env dist/$(OUT)/
-cp customers/$(CUSTOMER)/logo.* dist/$(OUT)/ 2>/dev/null
cp deploy/csat.service deploy/install.sh deploy/update.sh deploy/csat-update.service deploy/csat-update.timer dist/$(OUT)/
cp deploy/nginx-csat.conf.example deploy/apache-csat.conf.example dist/$(OUT)/
cp INSTALL.md README.md survey.example.json dist/$(OUT)/
-cp customers/$(CUSTOMER)/DEPLOY.md dist/$(OUT)/ 2>/dev/null
chmod +x dist/$(OUT)/csat dist/$(OUT)/install.sh dist/$(OUT)/update.sh
tar -C dist -czf dist/$(OUT).tar.gz $(OUT)
@echo "packaged: dist/$(OUT).tar.gz"
@ls -lh dist/$(OUT).tar.gz
run:
go run ./cmd/csat -config config.toml
test:
go test ./...
vet:
go vet ./...
fmt:
gofmt -w .
tidy:
go mod tidy
clean:
rm -rf dist