-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
42 lines (35 loc) · 1.07 KB
/
Makefile
File metadata and controls
42 lines (35 loc) · 1.07 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
SHELL = /bin/bash
TARGET = lot
VERSION = v0.0.1
GIT_REPO_PATH = $(shell git remote -v | grep fetch | awk '{print $$2}'| sed -e 's/^git@//' | sed -e 's/.git$$//' | sed -e 's/:/\//')
DOCKER_BIN = $(shell which docker)
DOCKER_RUN = $(DOCKER_BIN) run --rm
DOCKER_FLAGS = --volume $(GO_SRC):/go/src \
--volume $(shell pwd):/go/src/$(GIT_REPO_PATH) \
--workdir /go/src/$(GIT_REPO_PATH)
GO_IMAGE = golang
GO_SRC = $(shell [ -n $$GOPATH/src ] && echo $$GOPATH/src || $(DOCKER_BIN) volume create go_src)
GO_FLAGS = -v
GO_OS = darwin linux
GO_ARCH = 386 amd64 arm arm64
build: install
$(DOCKER_RUN) \
$(DOCKER_FLAGS) \
$(GO_IMAGE) \
go build $(GO_FLAGS) -o main .
release: install
$(foreach GOOS,$(GO_OS),\
$(foreach GOARCH,$(GO_ARCH),\
$(DOCKER_RUN) \
$(DOCKER_FLAGS) \
-e GOOS=$(GOOS) \
-e GOARCH=$(GOARCH) \
$(GO_IMAGE) \
go build $(GO_FLAGS) -o build/$(TARGET)-$(VERSION)-$(GOOS)-$(GOARCH) .;\
)\
)
file build/*
install:
$(DOCKER_RUN) $(DOCKER_FLAGS) $(GO_IMAGE) go get
shell:
$(DOCKER_RUN) $(DOCKER_FLAGS) -it $(GO_IMAGE) bash