Makefile

v1.5.2
skunky-art/Makefile history · blame · raw

39 lines · 1381 bytes

 1# Build, test and package SkunkyArt. VERSION comes from the nearest tag so a
 2# local build reports the same version a release of that commit would.
 3
 4VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null | sed 's/^v//')
 5LDFLAGS  = -s -w -X main.version=$(VERSION)
 6GOFLAGS  = -trimpath -buildvcs=false
 7LINT     = github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.13.2
 8
 9# os/arch pairs packaged by `make dist`.
10PLATFORMS = linux/amd64 linux/arm64 darwin/arm64 freebsd/amd64
11
12.PHONY: build test lint dist clean
13
14build:
15	CGO_ENABLED=0 go build $(GOFLAGS) -tags embed -ldflags "$(LDFLAGS)" -o skunkyart .
16
17test:
18	go test ./... -race -count=1
19
20lint:
21	go run $(LINT) run ./...
22
23# One tar.gz per platform under dist/, each holding the embed-tag binary,
24# the example config and the docs, with a checksum file beside them.
25dist:
26	rm -rf dist && mkdir -p dist
27	set -e; for p in $(PLATFORMS); do \
28	  os=$${p%/*}; arch=$${p#*/}; dir=dist/skunkyart-$(VERSION)-$$os-$$arch; \
29	  mkdir -p $$dir; \
30	  CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build $(GOFLAGS) -tags embed -ldflags "$(LDFLAGS)" -o $$dir/skunkyart .; \
31	  cp config.example.json README.org SETUP.md API.md LICENSE $$dir/; \
32	  cp -r services $$dir/; \
33	  tar -C dist -czf $$dir.tar.gz $$(basename $$dir); \
34	  rm -r $$dir; \
35	done
36	cd dist && shasum -a 256 *.tar.gz > SHA256SUMS
37
38clean:
39	rm -rf dist skunkyart