From c96089116d862e753468dab453dc7ff2adf30fa9 Mon Sep 17 00:00:00 2001 From: appleboy Date: Sun, 6 Oct 2024 10:08:58 +0800 Subject: [PATCH] chore: simplify and clean up build and release processes - Update `GOFMT` command to include `-s` and `-w` flags - Remove redundant `DIST` and `DIST_DIRS` definitions - Remove unused variables and dependencies - Remove `.PHONY` targets and associated release tasks - Simplify `clean` target by removing `$(DIST)` directory from the removal list Signed-off-by: appleboy --- Makefile | 59 ++------------------------------------------------------ 1 file changed, 2 insertions(+), 57 deletions(-) diff --git a/Makefile b/Makefile index a260503..4cffdec 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,9 @@ DIST := dist EXECUTABLE := drone-discord -GOFMT ?= gofumpt -l -DIST := dist -DIST_DIRS := $(DIST)/binaries $(DIST)/release +GOFMT ?= gofumpt -l -s -w GO ?= go -SHASUM ?= shasum -a 256 GOFILES := $(shell find . -name "*.go" -type f) HAS_GO = $(shell hash $(GO) > /dev/null 2>&1 && echo "GO" || echo "NOGO" ) -XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest -XGO_VERSION := go-1.19.x -GXZ_PAGAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11 - -LINUX_ARCHS ?= linux/amd64,linux/arm64 -DARWIN_ARCHS ?= darwin-10.12/amd64,darwin-10.12/arm64 -WINDOWS_ARCHS ?= windows/* ifneq ($(shell uname), Darwin) EXTLDFLAGS = -extldflags "-static" $(null) @@ -89,54 +79,9 @@ build_linux_amd64: build_linux_arm64: CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GO) build -a -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' -o release/linux/arm64/$(DEPLOY_IMAGE) -.PHONY: deps-backend -deps-backend: - $(GO) mod download - $(GO) install $(GXZ_PAGAGE) - $(GO) install $(XGO_PACKAGE) - -.PHONY: release -release: release-linux release-darwin release-windows release-copy release-compress release-check - -$(DIST_DIRS): - mkdir -p $(DIST_DIRS) - -.PHONY: release-windows -release-windows: | $(DIST_DIRS) - CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -buildmode exe -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(WINDOWS_ARCHS)' -out $(EXECUTABLE)-$(VERSION) . -ifeq ($(CI),true) - cp -r /build/* $(DIST)/binaries/ -endif - -.PHONY: release-linux -release-linux: | $(DIST_DIRS) - CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '-linkmode external -extldflags "-static" $(LDFLAGS)' -targets '$(LINUX_ARCHS)' -out $(EXECUTABLE)-$(VERSION) . -ifeq ($(CI),true) - cp -r /build/* $(DIST)/binaries/ -endif - -.PHONY: release-darwin -release-darwin: | $(DIST_DIRS) - CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets '$(DARWIN_ARCHS)' -out $(EXECUTABLE)-$(VERSION) . -ifeq ($(CI),true) - cp -r /build/* $(DIST)/binaries/ -endif - -.PHONY: release-copy -release-copy: | $(DIST_DIRS) - cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done; - -.PHONY: release-check -release-check: | $(DIST_DIRS) - cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "checksumming $${file}" && $(SHASUM) `echo $${file} | sed 's/^..//'` > $${file}.sha256; done; - -.PHONY: release-compress -release-compress: | $(DIST_DIRS) - cd $(DIST)/release/; for file in `find . -type f -name "*"`; do echo "compressing $${file}" && $(GO) run $(GXZ_PAGAGE) -k -9 $${file}; done; - clean: $(GO) clean -x -i ./... - rm -rf coverage.txt $(EXECUTABLE) $(DIST) + rm -rf coverage.txt $(EXECUTABLE) version: @echo $(VERSION)