From 738b1c67c0a79c2fa436fce8671b3fd7949c3bc8 Mon Sep 17 00:00:00 2001 From: tbxark Date: Thu, 9 May 2024 17:09:45 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E4=BC=98=E5=8C=96=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 40 +++++++++++++++++++++++++++++++++------- README.md | 4 ++++ 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index d6a47e4..7a01e55 100644 --- a/Makefile +++ b/Makefile @@ -1,28 +1,54 @@ BIN_NAME=github-backup +BUILD_DIR=./build BUILD=$(shell git rev-parse --short HEAD)@$(shell date +%s) CURRENT_OS := $(shell uname -s | tr '[:upper:]' '[:lower:]') CURRENT_ARCH := $(shell uname -m | tr '[:upper:]' '[:lower:]') -GO_BUILD=CGO_ENABLED=0 go build -ldflags "-X main.BuildVersion=$(BUILD)" +LD_FLAGS=-ldflags "-X main.BuildVersion=$(BUILD)" +GO_BUILD=CGO_ENABLED=0 go build $(LD_FLAGS) .PHONY: build build: - $(GO_BUILD) -o ./build/$(CURRENT_OS)_$(CURRENT_ARCH)/ ./... + $(GO_BUILD) -o ./build/$(BIN_NAME)_$(CURRENT_OS)_$(CURRENT_ARCH)/ ./... .PHONY: run run: - go run -ldflags "-X main.BuildVersion=$(BUILD)" . + go run $(LD_FLAGS) . .PHONY: install install: - go install -ldflags "-X main.BuildVersion=$(BUILD)" . + go install $(LD_FLAGS) . .PHONY: buildLinuxX86 buildLinuxX86: - GOOS=linux GOARCH=amd64 $(GO_BUILD) -o ./build/linux_x86/ ./... + GOOS=linux GOARCH=amd64 $(GO_BUILD) -o $(BUILD_DIR)/$(BIN_NAME)_linux_x86/ ./... + +.PHONY: buildLinuxARM64 +buildLinuxARM64: + GOOS=linux GOARCH=arm64 $(GO_BUILD) -o $(BUILD_DIR)/$(BIN_NAME)_linux_arm64/ ./... .PHONY: buildWindowsX86 buildWindowsX86: - GOOS=windows GOARCH=amd64 $(GO_BUILD) -o ./build/windows_x86/ ./... + GOOS=windows GOARCH=amd64 $(GO_BUILD) -o $(BUILD_DIR)/$(BIN_NAME)_windows_x86/ ./... + +.PHONY: buildWindowsARM64 +buildWindowsARM64: + GOOS=windows GOARCH=arm64 $(GO_BUILD) -o $(BUILD_DIR)/$(BIN_NAME)_windows_arm64/ ./... + +.PHONY: buildDarwinX86 +buildDarwinX86: + GOOS=darwin GOARCH=amd64 $(GO_BUILD) -o $(BUILD_DIR)/$(BIN_NAME)_darwin_x86/ ./... + +.PHONY: buildDarwinARM64 +buildDarwinARM64: + GOOS=darwin GOARCH=arm64 $(GO_BUILD) -o $(BUILD_DIR)/$(BIN_NAME)_darwin_arm64/ ./... .PHONY: buildAll -buildAll: buildLinuxX86 buildWindowsX86 build \ No newline at end of file +buildAll: buildLinuxX86 buildLinuxARM64 buildWindowsX86 buildWindowsARM64 buildDarwinX86 buildDarwinARM64 + +.PHONY: compressAll +compressAll: buildAll + @cd $(BUILD_DIR) && \ + for dir in */; do \ + base=$${dir%/}; \ + tar -czvf $${base}.tar.gz $${base}; \ + done diff --git a/README.md b/README.md index 2265609..9692bf5 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,14 @@ A simple tool to backup github repository to gitea or other provider. ### Installation +#### Build from source ```bash go install github.com/TBXark/github-backup@latest ```` +#### Download from release +Download the latest release from [release page](https://github.com/TBXark/github-backup/releases) + ### Usage ``` Usage of github-backup: