-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
53 lines (43 loc) · 1.03 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
# Go parameters
GO=go
GOBUILD=$(GO) build
GOCLEAN=$(GO) clean
GOTEST=$(GO) test
GOGET=$(GO) get
BUILDDIR=bin
NAME=docker-recreate
VERSION=$(shell cat VERSION.txt)
GOOSARCHES=$(shell cat .goosarch)
.PHONY: all
all: deps test build
.PHONY: build
build:
$(GOBUILD) -o bin/$(NAME) -v
.PHONY: install
install:
cp bin/$(NAME) ~/.docker/cli-plugins/
.PHONY: test
test:
$(GOTEST) -v ./...
.PHONY: clean
clean:
$(GOCLEAN)
rm -f bin/*
.PHONY: run
run:
$(GOBUILD) -o $(BUILDDIR)/$(NAME) -v ./...
./$(BUILDDIR)/$(NAME)
.PHONY: deps
deps:
$(GOGET) -v -t -d ./...
define buildrelease
GOOS=$(1) GOARCH=$(2) CGO_ENABLED=$(CGO_ENABLED) $(GOBUILD) \
-o $(BUILDDIR)/$(NAME)-$(1)-$(2) -a .;
endef
.PHONY: release
release: *.go VERSION.txt
$(foreach GOOSARCH,$(GOOSARCHES), $(call buildrelease,$(subst /,,$(dir $(GOOSARCH))),$(notdir $(GOOSARCH))))
.PHONY: tag
tag: ## Create a new git tag to prepare to build a release.
git tag -a $(VERSION) -m "$(VERSION)"
@echo "Run \"git push origin $(VERSION)\" to push your new tag to GitHub and trigger a release."