forked from groob/moroz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
82 lines (63 loc) · 2.17 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
all: build
.PHONY: build
ifndef ($(GOPATH))
GOPATH = $(HOME)/go
endif
export GO111MODULE=on
PATH := $(GOPATH)/bin:$(PATH)
VERSION = $(shell git describe --tags --always --dirty)
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
REVISION = $(shell git rev-parse HEAD)
REVSHORT = $(shell git rev-parse --short HEAD)
USER = $(shell whoami)
GOVERSION = $(shell go version | awk '{print $$3}')
NOW = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
SHELL = /bin/bash
DOCKER_IMAGE_NAME = groob/moroz
DOCKER_IMAGE_TAG = $(shell echo ${VERSION} | sed 's/^v//')
ifneq ($(OS), Windows_NT)
CURRENT_PLATFORM = linux
ifeq ($(shell uname), Darwin)
SHELL := /bin/bash
CURRENT_PLATFORM = darwin
endif
else
CURRENT_PLATFORM = windows
endif
BUILD_VERSION = "\
-X github.com/kolide/kit/version.appName=${APP_NAME} \
-X github.com/kolide/kit/version.version=${VERSION} \
-X github.com/kolide/kit/version.branch=${BRANCH} \
-X github.com/kolide/kit/version.buildUser=${USER} \
-X github.com/kolide/kit/version.buildDate=${NOW} \
-X github.com/kolide/kit/version.revision=${REVISION} \
-X github.com/kolide/kit/version.goVersion=${GOVERSION}"
gomodcheck:
@go help mod > /dev/null || (@echo micromdm requires Go version 1.11 or higher && exit 1)
deps: gomodcheck
@go mod download
test:
go test -cover -race -v $(shell go list ./... | grep -v /vendor/)
build: moroz
clean:
rm -rf build/
rm -f *.zip
.pre-build:
mkdir -p build/darwin
mkdir -p build/linux
.pre-moroz:
$(eval APP_NAME = moroz)
moroz: .pre-build .pre-moroz
go build -o build/$(CURRENT_PLATFORM)/moroz -ldflags ${BUILD_VERSION} ./cmd/moroz
xp-moroz: .pre-build .pre-moroz
GOOS=darwin go build -o build/darwin/moroz -ldflags ${BUILD_VERSION} ./cmd/moroz
GOOS=linux CGO_ENABLED=0 go build -o build/linux/moroz -ldflags ${BUILD_VERSION} ./cmd/moroz
install: .pre-moroz
go install -ldflags ${BUILD_VERSION} ./cmd/moroz
release-zip: xp-moroz
zip -r moroz_${VERSION}.zip build/
docker-build:
GOOS=linux CGO_ENABLED=0 go build -o build/linux/moroz -ldflags ${BUILD_VERSION} ./cmd/moroz
docker build -t ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} .
docker-tag: docker-build
docker tag ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} ${DOCKER_IMAGE_NAME}:latest