configui/Makefile

74 lines
2.0 KiB
Makefile
Raw Normal View History

2021-10-18 08:49:16 +00:00
VERSION=$(shell git describe --tags --abbrev=0)
BUILD=$(shell git rev-parse --short HEAD)
PROJ := $(shell basename "$(PWD)")
HUB=hub.kumoly.io
HUB_PROJECT=tools
LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD} -w"
2021-10-20 16:19:32 +00:00
PLATFORMS=darwin linux
ARCHITECTURES=amd64
APPS=configui
2021-10-18 08:49:16 +00:00
default: build
2021-10-20 16:19:32 +00:00
install:
npm install
2021-10-18 15:53:49 +00:00
clean:
rm -rf dist
run: build
$(shell cd dist; ./${PROJ} -log configui.log)
2021-10-21 13:49:15 +00:00
.PHONY: web
web:
npm run build
2021-10-23 04:55:05 +00:00
# npm run js-dev
2021-10-21 13:49:15 +00:00
.PHONY: build
2021-10-23 04:55:05 +00:00
build:
2021-10-21 13:49:15 +00:00
go build ${LDFLAGS} -o dist/${PROJ} cmd/$(PROJ)/main.go
2021-10-20 16:19:32 +00:00
build-unix:
$(foreach GOOS, $(PLATFORMS), $(foreach GOARCH, $(ARCHITECTURES), $(foreach APP, $(APPS),\
2021-10-21 13:49:15 +00:00
$(shell export GOOS=$(GOOS); export GOARCH=$(GOARCH); go build ${LDFLAGS} -o dist/$(APP) cmd/$(APP)/main.go) \
2021-10-20 16:19:32 +00:00
$(shell cd dist; tar -czf ${APP}_$(VERSION)_$(GOOS)_$(GOARCH).tar.gz ${APP}) \
$(shell rm dist/${APP}) \
)))
build-win:
$(foreach APP, $(APPS), \
2021-10-21 13:49:15 +00:00
$(shell export GOOS=windows; export GOARCH=amd64; go build ${LDFLAGS} -o dist/${APP}.exe cmd/$(APP)/main.go) \
2021-10-20 16:19:32 +00:00
$(shell cd dist; tar -czf ${APP}_$(VERSION)_windows_amd64.tar.gz ${APP}.exe) \
$(shell rm dist/${APP}.exe) \
)
build-mac-m1:
$(foreach APP, $(APPS),\
2021-10-21 13:49:15 +00:00
$(shell export GOOS=darwin; export GOARCH=arm64; go build ${LDFLAGS} -o dist/$(APP) cmd/$(APP)/main.go) \
2021-10-20 16:19:32 +00:00
$(shell cd dist; tar -czf ${APP}_$(VERSION)_darwin_arm64.tar.gz ${APP}) \
$(shell rm dist/${APP}) \
)
.PHONY: binary
binary: build-unix build-win build-mac-m1
.PHONY: docker
docker:
docker build --target builder -t $(HUB)/$(HUB_PROJECT)/$(PROJ):builder .
docker build \
-t $(HUB)/$(HUB_PROJECT)/$(PROJ):$(VERSION) \
.
docker-push:
docker tag $(HUB)/$(HUB_PROJECT)/$(PROJ):$(VERSION) $(HUB)/$(HUB_PROJECT)/$(PROJ):latest
docker push $(HUB)/$(HUB_PROJECT)/$(PROJ):$(VERSION)
docker push $(HUB)/$(HUB_PROJECT)/$(PROJ):latest
docker-save:
docker save $(HUB)/$(HUB_PROJECT)/$(PROJ):$(VERSION) | gzip > dist/$(PROJ)-image-$(VERSION)-${BUILD}.tar.gz
.PHONY: release
2021-10-21 13:49:15 +00:00
release: clean web binary docker docker-save