-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile.variables
53 lines (46 loc) · 1.35 KB
/
Makefile.variables
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
PROJECT_FILE = project.yml
export PROJECT = $(shell awk '/name: / { print $$2; exit }' ${PROJECT_FILE})
IMPORT_PATH = $(shell awk '/import: / { print $$2; exit }' ${PROJECT_FILE})
CI ?=
ifeq ($(strip $(CI)),)
CI_ENABLED := 0
else
CI_ENABLED := 1
endif
# major, minor, patch
RELEASE_TYPE ?=
GITHUB_TOKEN ?=
# Windows environment?
CYG_CHECK := $(shell hash cygpath 2>/dev/null && echo 1)
# WSL environment?
WSL_CHECK := $(shell grep -qE "(Microsoft)" /proc/version 2>/dev/null && echo 1)
ifeq ($(CYG_CHECK),1)
VBOX_CHECK := $(shell hash VBoxManage 2>/dev/null && echo 1)
# Docker Toolbox (pre-Windows 10)
ifeq ($(VBOX_CHECK),1)
ROOT := /${PROJECT}
else
# Docker Windows
ROOT := $(shell cygpath -m -a "$(shell pwd)")
endif
else ifeq ($(WSL_CHECK),1)
# requires drives shared in Docker for Windows settings
ROOT := $(strip $(shell cmd.exe /c cd | sed -e 's/\\/\//g'))
else
# all non-windows environments
ROOT := $(shell pwd)
endif
DEV_IMAGE := ${PROJECT}_dev
DOCKERRUN := docker run --rm \
-e PROJECT_FILE="${PROJECT_FILE}" \
-v ${ROOT}/.mod:/go/pkg/mod \
-v ${ROOT}:/usr/src/${PROJECT} \
-w /usr/src/${PROJECT} \
${DEV_IMAGE}
DOCKERNOVENDOR := docker run --rm -i \
-e PROJECT_FILE="${PROJECT_FILE}" \
-e RELEASE_TYPE="${RELEASE_TYPE}" \
-e GITHUB_TOKEN="${GITHUB_TOKEN}" \
-v ${ROOT}:/usr/src/${PROJECT} \
-w /usr/src/${PROJECT} \
${DEV_IMAGE}