-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
39 lines (32 loc) · 1.05 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
.PHONY: arch clean docker docker-force install test
BIN := op-bot
BINDIR := /usr/local/bin
ARCHDIR := arch
SRC := $(wildcard src/*.go)
GIT_TAG := $(shell git describe --always --tags)
# Default target
${BIN}: Makefile ${SRC}
cd src && go build -v -ldflags "-X main.BuildVersion=${GIT_TAG}" -o "../${BIN}"
install: ${BIN}
install -m 755 "${BIN}" "${BINDIR}"
docker:
docker build -t ${BIN}:latest .
test:
cd src && go test -v
# Cleanup
clean:
cd src && go clean || true
rm -f "${BIN}"
rm -rf "${ARCHDIR}"
docker builder prune -f
# Creates cross-compiled tarred versions (for releases).
arch: Makefile ${SRC}
for ga in "linux/amd64" "linux/386" "linux/arm" "linux/arm64" "linux/mips" "linux/mipsle"; do \
export goos="$${ga%/*}"; \
export goarch="$${ga#*/}"; \
dst="./${ARCHDIR}/$${goos}-$${goarch}"; \
mkdir -p "$${dst}"; \
go build -v -ldflags "-X main.Build=${GIT_TAG}" -o "$${dst}/${BIN}"; \
install -m 644 LICENSE README.md "$${dst}"; \
tar -C "${ARCHDIR}" -zcvf "${ARCHDIR}/${BIN}-$${goos}-$${goarch}.tar.gz" "$${dst##*/}"; \
done