-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
32 lines (26 loc) · 1.14 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
DEBUG_FLAG = $(if $(DEBUG), -debug)
VERSION_GO = version.go
_NAME = $(shell grep -o 'AppName string = "[^"]*"' $(VERSION_GO) | cut -d '"' -f2)
_VERSION = $(shell grep -oE 'Version string = "[0-9]+\.[0-9]+\.[0-9]+"' $(VERSION_GO) | cut -d '"' -f2)
.PHONY: build
build:
docker build --build-arg VERSION=$(_VERSION) -t $(_NAME):$(_VERSION) .
docker tag $(_NAME):$(_VERSION) $(_NAME):latest
.PHONY: ghpkg
ghpkg:
docker tag $(_NAME):$(_VERSION) docker.pkg.github.com/octu0/revproxy/$(_NAME):$(_VERSION)
docker push docker.pkg.github.com/octu0/revproxy/$(_NAME):$(_VERSION)
.PHONY: pkg
pkg: build
mkdir -p "$(PWD)/pkg"
$(eval binpath_linux := "$(PWD)/pkg/$(_NAME)_linux_amd64-$(_VERSION)")
$(eval binpath_darwin := "$(PWD)/pkg/$(_NAME)_darwin_amd64-$(_VERSION)")
$(eval cid := $(shell docker create $(_NAME):$(_VERSION)))
docker cp $(cid):/app/$(_NAME) "$(binpath_linux)"
docker cp $(cid):/app/$(_NAME)_darwin "$(binpath_darwin)"
docker rm -v $(cid)
zip -j "$(binpath_linux).zip" "$(binpath_linux)"
zip -j "$(binpath_darwin).zip" "$(binpath_darwin)"
.PHONY: ghauth
ghauth:
cat ~/.GH_TOKEN | docker login -u --password-stdin docker.pkg.github.com