-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (41 loc) · 1.41 KB
/
Makefile
File metadata and controls
57 lines (41 loc) · 1.41 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
APP_NAME=$(shell basename $(shell git remote get-url origin))
# Registry name
REGISTRY=chubasic
# Get git tag and current commit hash as registry tag name
VERSION=$(shell git describe --tags --abbrev=0)-$(shell git rev-parse --short HEAD)
# lowercase -cmd OS name->os name
TARGETOS=$(shell echo $$(uname) | tr 'A-Z' 'a-z') # darwin windows linux
ARCH=$(shell uname -m)
# DOCKER_ARCH=$(shell dpkg --print-architecture)
TARGET_ARCH=arm64 #amd64
DARWIN=darwin
LINUX=linux
CHART_NAME=helm
format:
gofmt -s -w ./
lint:
golint
test:
go test -v
install:
go get
build: install
go build -v -o koobrabot -ldflags "-X="github.com/Chubasic/koobrabot/cmd.app_version=${VERSION}
linux:
CGO_ENABLED=0 GOOS=${LINUX} GOARCH=${TARGET_ARCH} $(MAKE) build
mac:
CGO_ENABLED=0 GOOS=${DARWIN} GOARCH=${TARGET_ARCH} $(MAKE) build
windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(MAKE) build
image:
docker build . -t ${REGISTRY}/${APP_NAME}:${VERSION}-${TARGET_ARCH} --build-arg TARGET_ARCH=${TARGET_ARCH} --build-arg CMD=${TARGETOS}
image-chart:
docker build . -t ${REGISTRY}/${CHART_NAME}:${VERSION}-${TARGET_ARCH} --build-arg TARGET_ARCH=${TARGET_ARCH} --build-arg CMD=${TARGETOS}
push:
docker push ${REGISTRY}/${APP_NAME}:${VERSION}-${TARGET_ARCH}
push-chart:
docker push ${REGISTRY}/${CHART_NAME}:${VERSION}-${TARGET_ARCH}
# clean:
# rm -rf koobrabot
clean:
docker rmi ${REGISTRY}/${APP_NAME}:${VERSION}-${TARGET_ARCH}