-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
66 lines (48 loc) · 2.39 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
VERSION?=$(shell git describe --tags --dirty | sed 's/^v//')
PKG=github.com/manifoldco/terraform-provider-manifold
GO_BUILD=CGO_ENABLED=0 go build -i --ldflags="-w -X $(PKG)/config.Version=$(VERSION)"
PROMULGATE_VERSION=0.0.9
ci: lint test
.PHONY: ci
#################################################
# Test and linting
#################################################
test:
@CGO_ENABLED=0 go test -v ./...
lint:
go run github.com/golangci/golangci-lint/cmd/golangci-lint run ./...
.PHONY: lint test
#################################################
# Building
#################################################
PREFIX?=
SUFFIX=
ifeq ($(GOOS),windows)
SUFFIX=.exe
endif
build: $(PREFIX)bin/terraform-provider-manifold$(SUFFIX)
$(PREFIX)bin/terraform-provider-manifold$(SUFFIX):
$(GO_BUILD) -o $(PREFIX)bin/terraform-provider-manifold$(SUFFIX) .
.PHONY: build $(PREFIX)bin/terraform-provider-manifold$(SUFFIX)
NO_WINDOWS= \
darwin_amd64 \
linux_amd64
OS_ARCH= \
$(NO_WINDOWS) \
windows_amd64
os=$(word 1,$(subst _, ,$1))
arch=$(word 2,$(subst _, ,$1))
os-build/windows_amd64/bin/terraform-provider-manifold: os-build/%/bin/terraform-provider-manifold:
PREFIX=build/$*/ GOOS=$(call os,$*) GOARCH=$(call arch,$*) make build/$*/bin/terraform-provider-manifold.exe
$(NO_WINDOWS:%=os-build/%/bin/terraform-provider-manifold): os-build/%/bin/terraform-provider-manifold:
PREFIX=build/$*/ GOOS=$(call os,$*) GOARCH=$(call arch,$*) make build/$*/bin/terraform-provider-manifold
build/terraform-provider-manifold_$(VERSION)_windows_amd64.zip: build/terraform-provider-manifold_$(VERSION)_%.zip: os-build/%/bin/terraform-provider-manifold
cd build/$*/bin; zip -r ../../terraform-provider-manifold_$(VERSION)_$*.zip terraform-provider-manifold.exe
$(NO_WINDOWS:%=build/terraform-provider-manifold_$(VERSION)_%.tar.gz): build/terraform-provider-manifold_$(VERSION)_%.tar.gz: os-build/%/bin/terraform-provider-manifold
cd build/$*/bin; tar -czf ../../terraform-provider-manifold_$(VERSION)_$*.tar.gz terraform-provider-manifold
zips: $(NO_WINDOWS:%=build/terraform-provider-manifold_$(VERSION)_%.tar.gz) build/terraform-provider-manifold_$(VERSION)_windows_amd64.zip
release: zips
curl -LO https://releases.manifold.co/promulgate/$(PROMULGATE_VERSION)/promulgate_$(PROMULGATE_VERSION)_linux_amd64.tar.gz
tar xvf promulgate_*
./promulgate release --homebrew=false v$(VERSION)
.PHONY: release zips $(OS_ARCH:%=os-build/%/bin/manifold)