-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
58 lines (46 loc) · 1.62 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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:]')
LD_FLAGS=-ldflags "-X main.BuildVersion=$(BUILD)"
GO_BUILD=CGO_ENABLED=0 go build $(LD_FLAGS)
.PHONY: build
build:
$(GO_BUILD) -o $(BUILD_DIR)/ ./...
.PHONY: run
run:
go run $(LD_FLAGS) .
.PHONY: install
install:
go install $(LD_FLAGS) .
.PHONY: buildLinuxX86
buildLinuxX86:
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_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 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
.PHONY: buildImage
buildImage:
docker buildx build --platform=linux/amd64,linux/arm64 -t ghcr.io/tbxark/github-backup:latest . --push --provenance=false