myip/Makefile

47 lines
1.3 KiB
Makefile
Raw Normal View History

2021-10-15 16:58:49 +00:00
VERSION=$(shell git describe --tags)
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"
PLATFORMS=darwin linux windows
ARCHITECTURES=amd64
default: build
install:
go mod tidy
go mod download
clean:
rm -rf dist
2021-10-15 08:17:56 +00:00
build:
2021-10-15 16:58:49 +00:00
go build ${LDFLAGS} -o dist/myip
build-bins:
$(foreach GOOS, $(PLATFORMS), $(foreach GOARCH, $(ARCHITECTURES), \
$(shell export GOOS=$(GOOS); export GOARCH=$(GOARCH); go build ${LDFLAGS} -o dist/$(PROJ)_$(VERSION)_$(GOOS)_$(GOARCH))))
build-m1:
$(shell export GOOS=darwin; export GOARCH=arm64; go build ${LDFLAGS} -o dist/$(PROJ)_$(VERSION)_darwin_arm64)
docker:
docker build --target builder -t $(HUB)/$(HUB_PROJECT)/$(PROJ):builder .
docker build \
-t $(HUB)/$(HUB_PROJECT)/$(PROJ):$(VERSION) \
.
2021-10-15 17:20:39 +00:00
docker-push:
2021-10-15 16:58:49 +00:00
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
2021-10-15 17:20:39 +00:00
docker-save:
2021-10-15 16:58:49 +00:00
docker save -o dist/$(PROJ)-$(VERSION)-${BUILD}.tar $(HUB)/$(HUB_PROJECT)/$(PROJ):$(VERSION)
2021-10-15 10:57:15 +00:00
2021-10-15 17:20:39 +00:00
release: build-bins build-m1 docker docker-save docker-push
2021-10-15 16:58:49 +00:00
.PHONY: build docker release clean all