-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (51 loc) · 3.98 KB
/
Makefile
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
BUILD_DIR = builds
MODULE = github.com/soerenschneider/dyndns
BINARY_NAME_SERVER = dyndns-server
BINARY_NAME_CLIENT = dyndns-client
CHECKSUM_FILE = $(BUILD_DIR)/checksum.sha256
SIGNATURE_KEYFILE = ~/.signify/github.sec
DOCKER_PREFIX = ghcr.io/soerenschneider
tests:
go test ./... -tags client,server -cover
clean:
rm -rf ./$(BUILD_DIR)
build: version-info
go build -race -ldflags="-w -X '$(MODULE)/internal.BuildVersion=${VERSION}' -X '$(MODULE)/internal.CommitHash=${COMMIT_HASH}'" -o $(BINARY_NAME_SERVER) -tags server cmd/server/server.go
go build -race -ldflags="-w -X '$(MODULE)/internal.BuildVersion=${VERSION}' -X '$(MODULE)/internal.CommitHash=${COMMIT_HASH}'" -o $(BINARY_NAME_CLIENT) -tags client cmd/client/client.go
release: clean version-info cross-build-client cross-build-server
sha256sum $(BUILD_DIR)/dyndns-* > $(CHECKSUM_FILE)
signed-release: release
pass keys/signify/github | signify -S -s $(SIGNATURE_KEYFILE) -m $(CHECKSUM_FILE)
gh-upload-assets -o soerenschneider -r dyndns -f ~/.gh-token builds
lambda-server:
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags server,aws -ldflags="-w -X '$(MODULE)/internal.BuildVersion=${VERSION}' -X '$(MODULE)/internal.CommitHash=${COMMIT_HASH}'" -o bootstrap cmd/server/server_lambda.go
rm -f dyndns-server-lambda.zip
zip dyndns-server-lambda.zip bootstrap
rm -f bootstrap
cross-build-server:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -X '$(MODULE)/internal.BuildVersion=${VERSION}' -X '$(MODULE)/internal.CommitHash=${COMMIT_HASH}'" -o $(BUILD_DIR)/$(BINARY_NAME_SERVER)-linux-x86_64 -tags server cmd/server/server.go
GOOS=linux GOARCH=arm GOARM=5 CGO_ENABLED=0 go build -ldflags="-w -X '$(MODULE)/internal.BuildVersion=${VERSION}' -X '$(MODULE)/internal.CommitHash=${COMMIT_HASH}'" -o $(BUILD_DIR)/$(BINARY_NAME_SERVER)-linux-armv5 -tags server cmd/server/server.go
GOOS=linux GOARCH=arm GOARM=6 CGO_ENABLED=0 go build -ldflags="-w -X '$(MODULE)/internal.BuildVersion=${VERSION}' -X '$(MODULE)/internal.CommitHash=${COMMIT_HASH}'" -o $(BUILD_DIR)/$(BINARY_NAME_SERVER)-linux-armv6 -tags server cmd/server/server.go
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-w -X '$(MODULE)/internal.BuildVersion=${VERSION}' -X '$(MODULE)/internal.CommitHash=${COMMIT_HASH}'" -o $(BUILD_DIR)/$(BINARY_NAME_SERVER)-linux-aarch64 -tags server cmd/server/server.go
cross-build-client:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -X '$(MODULE)/internal.BuildVersion=${VERSION}' -X '$(MODULE)/internal.CommitHash=${COMMIT_HASH}'" -o $(BUILD_DIR)/$(BINARY_NAME_CLIENT)-linux-x86_64 -tags client cmd/client/client.go
GOOS=linux GOARCH=arm GOARM=5 CGO_ENABLED=0 go build -ldflags="-w -X '$(MODULE)/internal.BuildVersion=${VERSION}' -X '$(MODULE)/internal.CommitHash=${COMMIT_HASH}'" -o $(BUILD_DIR)/$(BINARY_NAME_CLIENT)-linux-armv5 -tags client cmd/client/client.go
GOOS=linux GOARCH=arm GOARM=6 CGO_ENABLED=0 go build -ldflags="-w -X '$(MODULE)/internal.BuildVersion=${VERSION}' -X '$(MODULE)/internal.CommitHash=${COMMIT_HASH}'" -o $(BUILD_DIR)/$(BINARY_NAME_CLIENT)-linux-armv6 -tags client cmd/client/client.go
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-w -X '$(MODULE)/internal.BuildVersion=${VERSION}' -X '$(MODULE)/internal.CommitHash=${COMMIT_HASH}'" -o $(BUILD_DIR)/$(BINARY_NAME_CLIENT)-linux-aarch64 -tags client cmd/client/client.go
docker-build-server:
docker build -t "$(DOCKER_PREFIX)/$(BINARY_NAME_SERVER)" --build-arg MODE=server .
docker-build-client:
docker build -t "$(DOCKER_PREFIX)/$(BINARY_NAME_CLIENT)" --build-arg MODE=client .
docker-build: docker-build-server docker-build-client
version-info:
$(eval VERSION := $(shell git describe --tags --abbrev=0 || echo "dev"))
$(eval COMMIT_HASH := $(shell git rev-parse HEAD))
fmt:
find . -iname "*.go" -exec go fmt {} \;
pre-commit-init:
pre-commit install
pre-commit install --hook-type commit-msg
docs:
rm -rf go-diagrams
go run doc/main.go
cd go-diagrams && dot -Tpng diagram.dot > ../overview.png