-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (34 loc) · 1.27 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
NAME := blackhole
IMAGE := pete911/${NAME}
VERSION ?= dev
test:
go test -v -race -cover ./...
.PHONY:test
bench:
go test -bench=.
.PHONY:bench
build: test
go build -ldflags "-X main.Version=${VERSION}"
.PHONY:build
image:
docker build --build-arg version=${VERSION} -t ${IMAGE}:${VERSION} .
docker tag ${IMAGE}:${VERSION} ${IMAGE}:latest
.PHONY:image
push-image:
docker push ${IMAGE}:${VERSION}
docker push ${IMAGE}:latest
.PHONY:push-image
release:
# amd64
for GOOS in "linux" "darwin" "windows"; do \
BUILD_CMD="GOOS=$$GOOS GOARCH=amd64 go build -ldflags \"-X main.Version=${VERSION}\" -o releases/${NAME}" ; \
TAR_CMD="tar -czvf releases/${NAME}_$${GOOS}_amd64.tar.gz -C releases/ ${NAME} && rm releases/${NAME}" ; \
docker run --rm -it -v "${PWD}":/usr/src/app -w /usr/src/app -e CGO_ENABLED=0 golang:1.16-alpine sh -c "$$BUILD_CMD && $$TAR_CMD" ; \
done
# arm64
for GOOS in "darwin"; do \
BUILD_CMD="GOOS=$$GOOS GOARCH=arm64 go build -ldflags \"-X main.Version=${VERSION}\" -o releases/${NAME}" ; \
TAR_CMD="tar -czvf releases/${NAME}_$${GOOS}_arm64.tar.gz -C releases/ ${NAME} && rm releases/${NAME}" ; \
docker run --rm -it -v "${PWD}":/usr/src/app -w /usr/src/app -e CGO_ENABLED=0 golang:1.16-alpine sh -c "$$BUILD_CMD && $$TAR_CMD" ; \
done
.PHONY:release