forked from elastic/eck-diagnostics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (45 loc) · 1.73 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
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License 2.0;
# you may not use this file except in compliance with the Elastic License 2.0.
SHELL := /bin/bash
export GOBIN = $(shell pwd)/bin
export SNAPSHOT ?= true
export SHA1 ?= $(shell git rev-parse --short=8 --verify HEAD)
export VERSION ?= $(SHA1)
GO_LDFLAGS := -X github.com/elastic/eck-diagnostics/internal.buildVersion=$(VERSION) \
-X github.com/elastic/eck-diagnostics/internal.buildHash=$(SHA1) \
-X github.com/elastic/eck-diagnostics/internal.buildDate=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ') \
-X github.com/elastic/eck-diagnostics/internal.snapshotBuild=$(SNAPSHOT)
lint: $(GOBIN)/golangci-lint
$(GOBIN)/golangci-lint run
unit-tests:
go test -v ./...
GOOS ?= darwin linux windows
GOARCH ?= amd64 arm64
build-binary:
@ for os in $(GOOS); do \
for arch in $(GOARCH); do \
echo "-- build artefacts/eck-diagnostics-$${os}-$${arch}"; \
GCO_ENABLED=0 GOOS=$${os} GOARCH=$${arch} go build \
-mod readonly \
-ldflags "$(GO_LDFLAGS)" -a \
-o artefacts/eck-diagnostics-$${os}-$${arch} \
github.com/elastic/eck-diagnostics/cmd \
; \
done \
done
build-image:
drivah build .
build-push-image:
drivah build . --push
generate-notice.txt: $(GOBIN)/go-licence-detector
@ go list -m -json all | $(GOBIN)/go-licence-detector \
-noticeTemplate=build/notice/NOTICE.txt.tpl \
-noticeOut=NOTICE.txt \
-overrides=build/notice/overrides.json \
-includeIndirect
# tool dependencies
$(GOBIN)/go-licence-detector:
@ go install go.elastic.co/[email protected]
$(GOBIN)/golangci-lint:
@ go install github.com/golangci/golangci-lint/cmd/[email protected]