diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d443e75 --- /dev/null +++ b/Makefile @@ -0,0 +1,145 @@ +NAME := showipaddress +PACKAGE_NAME := github.com/egidijus/showipaddress +VERSION := $(shell git describe --tags || echo "unknown-version") +COMMIT := $(shell git rev-parse HEAD) +BUILDTIME := $(shell date -u "+%Y-%m-%d %H:%M:%S %Z") +BUILD_DIR := build +VAR_SETTING := -X "$(PACKAGE_NAME)/constant.Version=$(VERSION)" -X "$(PACKAGE_NAME)/constant.Commit=$(COMMIT)" -X "$(PACKAGE_NAME)/constant.BuildTime=$(BUILDTIME)" +GOBUILD = CGO_ENABLED=0 go build -trimpath -ldflags '-s -w -buildid= $(VAR_SETTING)' \ + -o $(BUILD_DIR) + +PLATFORM_LIST = \ + darwin-amd64 \ + darwin-arm64 \ + linux-amd64 \ + linux-arm64 \ + windows-amd64 \ + windows-arm64 + + +zip_release = $(addsuffix .zip, $(PLATFORM_LIST)) + + +.PHONY: build clean release +normal: clean build + +clean: + @rm -rf $(BUILD_DIR) + @echo "Cleaning up." + +$(zip_release): %.zip : % + @zip -du $(BUILD_DIR)/$(NAME)-$<-$(VERSION).zip -j -m $(BUILD_DIR)/$