diff --git a/Dockerfile b/Dockerfile index 7b29f67..13e5885 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,7 +9,7 @@ COPY . . RUN VERSION=$(git describe --tags) BUILD=$(git rev-parse --short HEAD) && \ GOOS=linux GOARCH=amd64 \ go build -ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD} -w" \ - -o /go/bin/myip main.go + -o /go/bin/myip cmd/myip/main.go FROM alpine:3.14 diff --git a/Makefile b/Makefile index 3bacfa0..2f74823 100644 --- a/Makefile +++ b/Makefile @@ -10,12 +10,8 @@ LDFLAGS=-ldflags "-X main.Version=${VERSION} -X main.Build=${BUILD} -w" PLATFORMS=darwin linux ARCHITECTURES=amd64 -BASIC_PATH=cmd/basic/main.go -BASIC=myip-basic -FULL_PATH=cmd/myip/main.go -FULL=myip -GUI_PATH=cmd/myip/main.go -GUI=cmd/myip/main.go + +APPS=myip myip-basic default: build @@ -34,25 +30,25 @@ build: go build ${LDFLAGS} -o dist/${FULL} ${FULL_PATH} build-unix: - $(foreach GOOS, $(PLATFORMS), $(foreach GOARCH, $(ARCHITECTURES), \ - $(shell export GOOS=$(GOOS); export GOARCH=$(GOARCH); go build ${LDFLAGS} -o dist/${FULL} ${FULL_PATH}) \ - $(shell cd dist; tar -czf ${FULL}_$(VERSION)_$(GOOS)_$(GOARCH).tar.gz ${FULL}) \ - )) - rm dist/${FULL} - - $(foreach GOOS, $(PLATFORMS), $(foreach GOARCH, $(ARCHITECTURES), \ - $(shell export GOOS=$(GOOS); export GOARCH=$(GOARCH); go build ${LDFLAGS} -o dist/${BASIC} ${BASIC_PATH}) \ - $(shell cd dist; tar -czf ${BASIC}_$(VERSION)_$(GOOS)_$(GOARCH).tar.gz ${BASIC}) \ - )) - rm dist/${BASIC} + $(foreach GOOS, $(PLATFORMS), $(foreach GOARCH, $(ARCHITECTURES), $(foreach APP, $(APPS),\ + $(shell export GOOS=$(GOOS); export GOARCH=$(GOARCH); go build ${LDFLAGS} -o dist/$(APP) cmd/$(APP)/main.go) \ + $(shell cd dist; tar -czf ${APP}_$(VERSION)_$(GOOS)_$(GOARCH).tar.gz ${APP}) \ + $(shell rm dist/${APP}) \ + ))) build-win: - $(shell export GOOS=windows; export GOARCH=amd64; go build ${LDFLAGS} -o dist/$(PROJ)_$(VERSION)_windows_amd64/${FULL}.exe ${FULL_PATH}) - $(shell export GOOS=windows; export GOARCH=amd64; go build ${LDFLAGS} -o dist/$(PROJ)-basic_$(VERSION)_windows_amd64/${BASIC}.exe ${BASIC_PATH}) + $(foreach APP, $(APPS), \ + $(shell export GOOS=windows; export GOARCH=amd64; go build ${LDFLAGS} -o dist/${APP}.exe cmd/$(APP)/main.go) \ + $(shell cd dist; tar -czf ${APP}_$(VERSION)_windows_amd64.tar.gz ${APP}.exe) \ + $(shell rm dist/${APP}.exe) \ + ) build-mac-m1: - $(shell export GOOS=darwin; export GOARCH=arm64; go build ${LDFLAGS} -o dist/$(PROJ)_$(VERSION)_darwin_arm64/${FULL} ${FULL_PATH}) - $(shell export GOOS=darwin; export GOARCH=arm64; go build ${LDFLAGS} -o dist/$(PROJ)-basic_$(VERSION)_darwin_arm64/${BASIC} ${BASIC_PATH}) + $(foreach APP, $(APPS),\ + $(shell export GOOS=darwin; export GOARCH=arm64; go build ${LDFLAGS} -o dist/$(APP) cmd/$(APP)/main.go) \ + $(shell cd dist; tar -czf ${APP}_$(VERSION)_darwin_arm64.tar.gz ${APP}) \ + $(shell rm dist/${APP}) \ + ) build-zip: cd dist; for f in * ;do if ! [[ $$f =~ "gz" ]] ; then tar -czf $${f}.tar.gz $${f}; fi done @@ -74,6 +70,7 @@ docker-save: docker save $(HUB)/$(HUB_PROJECT)/$(PROJ):$(VERSION) | gzip > dist/$(PROJ)-image-$(VERSION)-${BUILD}.tar.gz -release: clean binary build-zip docker docker-save docker-push +release: clean binary docker docker-save + .PHONY: build docker release clean all binary install \ No newline at end of file diff --git a/README.md b/README.md index 88a7200..671cca5 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ docker run --name myip -d --restart=always hub.kumoly.io/tools/myip myip --cron ## Cron ``` -ield name | Mandatory? | Allowed values | Allowed special characters +field name | Mandatory? | Allowed values | Allowed special characters ---------- | ---------- | -------------- | -------------------------- Seconds | Yes | 0-59 | * / , - Minutes | Yes | 0-59 | * / , - diff --git a/cmd/basic/main.go b/cmd/myip-basic/main.go similarity index 100% rename from cmd/basic/main.go rename to cmd/myip-basic/main.go