-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (44 loc) · 2.06 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
BUILD_DIR = builds
MODULE = github.com/soerenschneider/sc
BINARY_NAME = sc
CHECKSUM_FILE = $(BUILD_DIR)/checksum.sha256
SIGNATURE_KEYFILE = ~/.signify/github.sec
DOCKER_PREFIX = ghcr.io/soerenschneider
generate:
go generate ./...
install: build
cp sc ~/bin/
tests:
go test ./... -race -covermode=atomic -coverprofile=coverage.out
go tool cover -html=coverage.out -o=coverage.html
go tool cover -func=coverage.out -o=coverage.out
clean:
git diff --quiet || { echo 'Dirty work tree' ; false; }
rm -rf ./$(BUILD_DIR)
build: version-info generate
CGO_ENABLED=0 go build -ldflags="-w -X '$(MODULE)/internal.BuildVersion=${VERSION}' -X '$(MODULE)/internal.CommitHash=${COMMIT_HASH}'" -o $(BINARY_NAME) .
release: clean version-info cross-build
sha256sum $(BUILD_DIR)/sc-* > $(CHECKSUM_FILE)
signed-release: release
pass keys/signify/github | signify -S -s $(SIGNATURE_KEYFILE) -m $(CHECKSUM_FILE)
gh-upload-assets -o soerenschneider -r sc -f ~/.gh-token builds
cross-build: version-info
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)-linux-amd64 .
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)-linux-armv6 .
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)-linux-aarch64 .
docker-build:
docker build -t "$(DOCKER_PREFIX)/sc-server" .
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
pre-commit-update:
pre-commit autoupdate
.PHONY: docs
docs:
rm -rf docs/cli/*.md
go run -tags=docgen main.go --server=xxx docs