forked from infracost/infracost
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
57 lines (41 loc) · 1.57 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
BINARY := infracost
PKG := github.com/infracost/infracost/cmd/infracost
TERRAFORM_PROVIDER_INFRACOST_VERSION := latest
VERSION := $(shell scripts/get_version.sh HEAD $(NO_DIRTY))
LD_FLAGS := -ldflags="-X 'github.com/infracost/infracost/internal/version.Version=$(VERSION)'"
BUILD_FLAGS := $(LD_FLAGS) -i -v
DEV_ENV := dev
ifdef INFRACOST_ENV
DEV_ENV := $(INFRACOST_ENV)
endif
.PHONY: deps run build windows linux darwin build_all install release install_provider clean test fmt lint
deps:
go mod download
run:
env INFRACOST_ENV=$(DEV_ENV) go run $(LD_FLAGS) $(PKG) $(ARGS)
build:
CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/$(BINARY) $(PKG)
windows:
env GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/$(BINARY)-windows-amd64 $(PKG)
linux:
env GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/$(BINARY)-linux-amd64 $(PKG)
darwin:
env GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build $(BUILD_FLAGS) -o build/$(BINARY)-darwin-amd64 $(PKG)
build_all: build windows linux darwin
install:
CGO_ENABLED=0 go install $(BUILD_FLAGS) $(PKG)
release: build_all
cd build; tar -czf $(BINARY)-windows-amd64.tar.gz $(BINARY)-windows-amd64
cd build; tar -czf $(BINARY)-linux-amd64.tar.gz $(BINARY)-linux-amd64
cd build; tar -czf $(BINARY)-darwin-amd64.tar.gz $(BINARY)-darwin-amd64
install_provider:
scripts/install_provider.sh $(TERRAFORM_PROVIDER_INFRACOST_VERSION)
clean:
go clean
rm -rf build/$(BINARY)*
test:
INFRACOST_LOG_LEVEL=warn go test -timeout 20m $(LD_FLAGS) ./... $(or $(ARGS), -v -cover)
fmt:
go fmt ./...
lint:
golangci-lint run