-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
53 lines (41 loc) · 1.31 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
NAME = terraform-provider-convox
VERSION := v0.1.3
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
XC_OSARCH := darwin/amd64 linux/amd64
BUILD_DIR ?= build
DIST_DIR ?= dist
bindir ?= ~/.terraform.d/plugins
all: deps build
build: XC_OSARCH=$(GOOS)/$(GOARCH)
build: build-all
dev: bindir=./terraform
dev: install
install: $(BUILD_DIR)/$(GOOS)_$(GOARCH)/$(NAME)
install -m 755 $< $(DESTDIR)$(bindir)/$(NAME)
deps:
go get -u github.com/mitchellh/gox
go get -u github.com/github/hub
#$(addsuffix /$(NAME), $(addprefix $(BUILD_DIR)/, $(subst /,_,$(XC_OSARCH)))): $(BUILD_DIR)/%/$(NAME):
#$*
#$@
build-all:
-rm -rf dist
gox \
-ldflags "-X main.version=${VERSION}" \
-osarch="${XC_OSARCH}" \
-output="${BUILD_DIR}/{{.OS}}_{{.Arch}}/${NAME}"
clean:
-rm -rf $(BUILD_DIR)
-rm -rf $(DIST_DIR)
ARTIFACTS := $(shell find $(BUILD_DIR) -mindepth 1 -maxdepth 1 -type d)
dist:
mkdir -p ${DIST_DIR}
$(foreach dir, $(ARTIFACTS), \
tar -zcf "${DIST_DIR}/${NAME}_${VERSION}_$(shell basename ${dir}).tgz" -C $(dir) $(NAME);)
release:
git log --no-merges \
--format='%C(auto,green)* %s%C(auto,reset)%n%w(0,2,2)%+b' \
--reverse "$(git describe --abbrev=0 --tags)..HEAD" \
| hub release create --draft -m ${VERSION} -F - "${VERSION}" $(foreach file,$(wildcard ${DIST_DIR}/*), -a $(file))
.PHONY: all build clean