forked from dundee/disk_usage_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
65 lines (50 loc) · 2.27 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
NAME := disk_usage_exporter
PACKAGE := github.com/dundee/$(NAME)
VERSION := $(shell git describe --tags 2>/dev/null)
GIT_SHA := $(shell git rev-parse HEAD 2>/dev/null)
GOFLAGS ?= -buildmode=pie -trimpath -mod=readonly -modcacherw
LDFLAGS := -s -w -extldflags '-static' \
-X '$(PACKAGE)/build.BuildVersion=$(VERSION)' \
-X '$(PACKAGE)/build.BuildCommitSha=$(GIT_SHA)' \
-X '$(PACKAGE)/build.BuildDate=$(shell LC_ALL=en_US.UTF-8 date)'
all: clean build-all clean-uncompressed-dist shasums
run:
go run .
build:
@echo "Version: " $(VERSION)
mkdir -p dist
GOFLAGS="$(GOFLAGS)" CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)" -o dist/$(NAME) .
build-all:
@echo "Version: " $(VERSION)
-mkdir dist
-CGO_ENABLED=0 gox \
-os="darwin" \
-arch="amd64 arm64" \
-output="dist/disk_usage_exporter_{{.OS}}_{{.Arch}}" \
-ldflags="$(LDFLAGS)"
-CGO_ENABLED=0 gox \
-os="linux freebsd netbsd openbsd" \
-output="dist/disk_usage_exporter_{{.OS}}_{{.Arch}}" \
-ldflags="$(LDFLAGS)"
cd dist; CGO_ENABLED=0 GOOS=linux GOARM=5 GOARCH=arm go build -ldflags="$(LDFLAGS)" -o disk_usage_exporter_linux_armv5l ..
cd dist; CGO_ENABLED=0 GOOS=linux GOARM=6 GOARCH=arm go build -ldflags="$(LDFLAGS)" -o disk_usage_exporter_linux_armv6l ..
cd dist; CGO_ENABLED=0 GOOS=linux GOARM=7 GOARCH=arm go build -ldflags="$(LDFLAGS)" -o disk_usage_exporter_linux_armv7l ..
cd dist; GOFLAGS="$(GOFLAGS)" CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o disk_usage_exporter_linux_amd64 ..
cd dist; CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="$(LDFLAGS)" -o disk_usage_exporter_linux_arm64 ..
cd dist; for file in disk_usage_exporter_linux_* disk_usage_exporter_darwin_* disk_usage_exporter_netbsd_* disk_usage_exporter_openbsd_* disk_usage_exporter_freebsd_*; do tar czf $$file.tgz $$file; done
test:
go test -v ./...
coverage:
go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
coverage-html: coverage
go tool cover -html=coverage.txt
clean:
-rm -r dist
clean-uncompressed-dist:
find dist -type f -not -name '*.tgz' -not -name '*.zip' -delete
shasums:
cd dist; sha256sum * > sha256sums.txt
cd dist; gpg --sign --armor --detach-sign sha256sums.txt
release:
gh release create -t "$(VERSION)" $(VERSION) ./dist/*
.PHONY: run build clean test coverage coverage-html