generated from hashicorp/terraform-provider-scaffolding-framework
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
98 lines (75 loc) · 2.53 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
90
91
92
93
94
95
96
97
98
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)"
# Determine KERNEL and ARCH
UNAME_S:=$(shell uname -s)
UNAME_M:=$(shell uname -m)
ifeq ($(UNAME_S),Linux)
KERNEL:=linux
else ifeq ($(UNAME_S),Darwin)
KERNEL:=darwin
endif
ifeq ($(UNAME_M),x86_64)
ARCH=amd64
else ifeq ($(UNAME_M),arm64)
ARCH:=arm64
endif
.PHONY: build info fmt vet test clean install acctest local-dev-install docs
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: clean
@echo " -> Building"
mkdir -p bin
CGO_ENABLED=0 go build -trimpath -o bin/terraform-provider-akeneo
@echo "Built terraform-provider-akeneo"
acctest: build
TF_ACC=1 go test ./... $(TESTARGS)
install: build
cp bin/terraform-provider-akeneo $$GOPATH/bin/terraform-provider-akeneo
local: build install
clean:
# @git clean -f -d
rm -rf bin
docs:
go generate