-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
72 lines (58 loc) · 1.87 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
67
68
69
70
71
72
# Copyright (c) 2023 EPAM Systems, Inc.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://www.mozilla.org/en-US/MPL/2.0/.
.DEFAULT_GOAL := build
OS := $(shell go env GOOS)
export GOBIN := $(abspath .)/bin/$(OS)
export PATH := $(GOBIN):$(PATH)
REF ?= $(shell git rev-parse --abbrev-ref HEAD)
COMMIT ?= $(shell git rev-parse HEAD | cut -c-7)
BUILD_AT ?= $(shell date +"%Y.%m.%d %H:%M %Z")
install: bin/$(OS)/staticcheck bin/$(OS)/cel
bin/$(OS)/staticcheck:
go install honnef.co/go/tools/cmd/[email protected]
cel:
go install github.com/epam/hubctl/cmd/cel@latest
.PHONY: cel
deps:
go mod download
.PHONY: deps
build:
go build \
-o bin/$(OS)/hubctl \
-ldflags="-s -w \
-X 'github.com/epam/hubctl/cmd/hub/util.ref=$(REF)' \
-X 'github.com/epam/hubctl/cmd/hub/util.commit=$(COMMIT)' \
-X 'github.com/epam/hubctl/cmd/hub/util.buildAt=$(BUILD_AT)'" \
github.com/epam/hubctl/cmd/hub
.PHONY: build
build-with-api:
go build \
-o "bin/$(OS)/hubctl" \
-tags="api" \
-ldflags="-s -w \
-X 'github.com/epam/hubctl/cmd/hub/util.ref=$(REF)' \
-X 'github.com/epam/hubctl/cmd/hub/util.commit=$(COMMIT)' \
-X 'github.com/epam/hubctl/cmd/hub/util.buildAt=$(BUILD_AT)' \
-X 'github.com/epam/hubctl/cmd/hub/metrics.MetricsServiceKey=$(METRICS_API_SECRET)' \
-X 'github.com/epam/hubctl/cmd/hub/metrics.DDKey=$(DD_CLIENT_API_KEY)'" \
github.com/epam/hubctl/cmd/hub
.PHONY: build-with-api
fmt:
go fmt github.com/epam/hubctl/...
.PHONY: fmt
vet:
go vet -composites=false github.com/epam/hubctl/...
.PHONY: vet
staticcheck: bin/$(OS)/staticcheck
@$(GOBIN)/staticcheck github.com/epam/hubctl/...
.PHONY: staticcheck
test: deps
go test -race ./cmd/hub/...
.PHONY: test
clean:
@go clean -modcache -cache -testcache
@rm -rf bin/$(OS)*
.PHONY: clean