-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
89 lines (68 loc) · 2.91 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
SHELL := /bin/bash
DESCRIBE := $(shell git describe --match "v*" --always --tags)
DESCRIBE_PARTS := $(subst -, ,$(DESCRIBE))
VERSION_TAG := $(word 1,$(DESCRIBE_PARTS))
COMMITS_SINCE_TAG := $(word 2,$(DESCRIBE_PARTS))
VERSION := $(subst v,,$(VERSION_TAG))
VERSION_PARTS := $(subst ., ,$(VERSION))
MAJOR := $(word 1,$(VERSION_PARTS))
MINOR := $(word 2,$(VERSION_PARTS))
MICRO := $(word 3,$(VERSION_PARTS))
NEXT_MAJOR := $(shell echo $$(($(MAJOR)+1)))
NEXT_MINOR := $(shell echo $$(($(MINOR)+1)))
NEXT_MICRO = $(shell echo $$(($(MICRO)+1)))
ifeq ($(strip $(COMMITS_SINCE_TAG)),)
CURRENT_VERSION_MICRO := $(MAJOR).$(MINOR).$(MICRO)
CURRENT_VERSION_MINOR := $(CURRENT_VERSION_MICRO)
CURRENT_VERSION_MAJOR := $(CURRENT_VERSION_MICRO)
else
CURRENT_VERSION_MICRO := $(MAJOR).$(MINOR).$(NEXT_MICRO)
CURRENT_VERSION_MINOR := $(MAJOR).$(NEXT_MINOR).0
CURRENT_VERSION_MAJOR := $(NEXT_MAJOR).0.0
endif
DATE = $(shell date +'%d.%m.%Y')
TIME = $(shell date +'%H:%M:%S')
COMMIT := $(shell git rev-parse HEAD)
AUTHOR := $(firstword $(subst @, ,$(shell git show --format="%aE" $(COMMIT))))
BRANCH_NAME := $(shell git rev-parse --abbrev-ref HEAD)
TAG_MESSAGE = "$(TIME) $(DATE) $(AUTHOR) $(BRANCH_NAME)"
COMMIT_MESSAGE := $(shell git log --format=%B -n 1 $(COMMIT))
CURRENT_TAG_MICRO := "v$(CURRENT_VERSION_MICRO)"
CURRENT_TAG_MINOR := "v$(CURRENT_VERSION_MINOR)"
CURRENT_TAG_MAJOR := "v$(CURRENT_VERSION_MAJOR)"
uname_s := $(shell uname -s)
uname_m := $(shell uname -m)
l_uname_s = $(shell echo $(uname_s) | tr A-Z a-z)
l_uname_m = $(shell echo $(uname_m) | tr A-Z a-z)
KERNEL=$(l_uname_s)
ARCH=$(l_uname_m)
.PHONY: build info fmt vet test install acctest local-dev-install
all: build
info:
@echo "Global info"
@echo "$(KERNEL)"
@echo "$(ARCH)"
fmt:
@echo " -> checking code style"
@! gofmt -d $(shell find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
vet:
@echo " -> vetting code"
@go vet ./...
test:
@echo " -> testing code"
@go test -v ./...
build:
@echo " -> Building"
mkdir -p bin
CGO_ENABLED=0 go build -trimpath -o bin/terraform-provider-proxmox
@echo "Built terraform-provider-dutchis"
# to run only certain tests, run something of the form: make acctest TESTARGS='-run=TestAccProxmoxVmQemu_DiskSlot'
acctest: build
TF_ACC=1 go test ./proxmox $(TESTARGS)
install: build
cp bin/terraform-provider-dutchis $$GOPATH/bin/terraform-provider-dutchis
local-dev-install: build
@echo "Building this release $(CURRENT_VERSION_MICRO) on $(KERNEL)/$(ARCH)"
rm -rf ~/.terraform.d/plugins/localhost/dutchis/terraform
mkdir -p ~/.terraform.d/plugins/localhost/dutchis/terraform/$(MAJOR).$(MINOR).$(NEXT_MICRO)/$(KERNEL)_$(ARCH)/
cp bin/terraform-provider-dutchis ~/.terraform.d/plugins/localhost/dutchis/terraform/$(MAJOR).$(MINOR).$(NEXT_MICRO)/$(KERNEL)_$(ARCH)/