This repository was archived by the owner on Sep 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
52 lines (45 loc) · 1.43 KB
/
Makefile
File metadata and controls
52 lines (45 loc) · 1.43 KB
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
SHELL := /bin/bash
DOCKER_PRESENT := $(shell command -v docker 2> /dev/null)
GLIDE_PRESENT := $(shell command -v glide 2> /dev/null)
BINARY := goperator
VERSION ?= 0.1.0
export CGO_ENABLED := 0
.PHONY: deps
deps:
ifndef GLIDE_PRESENT
@ curl -sL https://glide.sh/get | bash
endif
@ go get github.com/mitchellh/gox
.PHONY: build
build: deps
@ echo "-> Installing $(BINARY) dependencies..."
@ glide install
@ echo "-> Building $(BINARY)..."
@ gox -os "darwin linux" -arch="386 amd64" \
-output="pkg/{{.Dir}}_{{.OS}}_{{.Arch}}"
.PHONY: docker-build
docker-build:
@ echo "-> Running $(BINARY) build in Docker..."
@ docker run --rm \
-v $(shell pwd):/go/src/github.com/mgar/$(BINARY) \
golang:1.8-alpine \
sh -c 'apk --update add curl bash git make && cd /go/src/github.com/mgar/$(BINARY) && make build'
.PHONY: _get_sys_arch
_get_sys_arch:
$(eval OS_NAME := $(shell echo $(shell uname -s) | tr '[:upper:]' '[:lower:]'))
$(eval ARCH := "386")
ifeq ($(shell uname -m), x86_64)
$(eval ARCH := "amd64")
endif
.PHONY: install
install: docker-build _get_sys_arch
@ echo "-> Moving binary to /usr/local/bin/$(BINARY)"
@ mv pkg/$(BINARY)_$(OS_NAME)_$(ARCH) /usr/local/bin/$(BINARY)
.PHONY: release
release: build
@ go get github.com/tcnksm/ghr
@ echo "-> Publishing $(BINARY) to GitHub..."
@ ghr -u mgar $(VERSION) pkg
.PHONE: tests
tests:
@ go test -v $(shell glide novendor) -cover -covermode=atomic -parallel=$(shell getconf _NPROCESSORS_ONLN)