-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters