forked from newrelic/nri-flex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
70 lines (54 loc) · 2.02 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
PROJECT_NAME := $(shell basename $(shell pwd))
NATIVEOS := $(shell go version | awk -F '[ /]' '{print $$4}')
NATIVEARCH := $(shell go version | awk -F '[ /]' '{print $$5}')
GO_PKGS := $(shell go list ./... | grep -v -e "/vendor/" -e "/example")
SRCDIR ?= .
BUILD_DIR := ./bin/
COVERAGE_DIR := ./coverage/
COVERMODE = atomic
GO_CMD = go
GODOC = godocdown
GOLINTER = golangci-lint
GOLINTER_VERSION = v1.24.0
GORELEASER_VERSION := v0.132.1
GORELEASER_SHA256 := 6c0145df61140ec1bffe4048b9ef3e105e18a89734816e7a64f342d3f9267691
GORELEASER_BIN ?= bin/goreleaser
# Determine packages by looking into pkg/*
ifneq ("$(wildcard ${SRCDIR}/pkg/*)","")
PACKAGES = $(wildcard ${SRCDIR}/pkg/*)
endif
ifneq ("$(wildcard ${SRCDIR}/internal/*)","")
PACKAGES += $(wildcard ${SRCDIR}/internal/*)
endif
# Determine commands by looking into cmd/*
COMMANDS = $(wildcard ${SRCDIR}/cmd/*)
# Determine binary names by stripping out the dir names
BINS=$(foreach cmd,${COMMANDS},$(notdir ${cmd}))
all: build
# Humans running make:
build: check-version clean lint test-unit coverage compile document
# Build command for CI tooling
build-ci: check-version clean lint test-integration
clean:
@echo "=== $(PROJECT_NAME) === [ clean ]: removing binaries and coverage file..."
@rm -rfv $(BUILD_DIR)/* $(COVERAGE_DIR)/*
bin:
@mkdir -p $(BUILD_DIR)
$(GORELEASER_BIN): bin
@echo "=== $(PROJECT) === [ release/deps ]: Installing goreleaser"
@(wget -qO /tmp/goreleaser.tar.gz https://github.com/goreleaser/goreleaser/releases/download/$(GORELEASER_VERSION)/goreleaser_$(GOOS)_x86_64.tar.gz)
@(tar -xf /tmp/goreleaser.tar.gz -C bin/)
@(rm -f /tmp/goreleaser.tar.gz)
release/deps: $(GORELEASER_BIN)
release: clean release/deps compile-only
@echo "=== $(PROJECT) === [ release ]: Releasing new version..."
@$(GORELEASER_BIN) release
# Import fragments
include build/deps.mk
include build/compile.mk
include build/setup.mk
include build/testing.mk
include build/util.mk
include build/document.mk
include build/docker.mk
.PHONY: all build build-ci