-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
41 lines (35 loc) · 1.09 KB
/
Makefile
File metadata and controls
41 lines (35 loc) · 1.09 KB
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
BINARY := ollamon
BUILD_DIR := bin
DIST_DIR := dist
MAIN_PKG := ./cmd/ollamon
GOCACHE := $(CURDIR)/.gocache
VERSION := 0.1.1
.PHONY: build run tidy clean dist
build:
mkdir -p $(BUILD_DIR)
mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) GOPROXY=off go build -o $(BUILD_DIR)/$(BINARY) $(MAIN_PKG)
run:
mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) GOPROXY=off go run $(MAIN_PKG)
tidy:
mkdir -p $(GOCACHE)
GOCACHE=$(GOCACHE) go mod tidy
clean:
rm -rf $(BUILD_DIR) $(GOCACHE)
dist:
mkdir -p $(GOCACHE)
$(MAKE) tidy
mkdir -p $(DIST_DIR)
@for target in darwin/amd64 darwin/arm64 linux/amd64 linux/arm64; do \
os=$${target%/*}; \
arch=$${target#*/}; \
echo "Building $$target..."; \
tmpdir=$$(mktemp -d); \
GOCACHE=$(GOCACHE) GOPROXY=off GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 go build -ldflags "-s -w -X main.version=v$(VERSION)" -o $$tmpdir/$(BINARY) $(MAIN_PKG); \
tar -C $$tmpdir -czf $(DIST_DIR)/$(BINARY)_$(VERSION)_$$os\_$$arch.tar.gz $(BINARY); \
rm -rf $$tmpdir; \
done
shasum -a 256 $(DIST_DIR)/*.tar.gz > $(DIST_DIR)/checksums.txt
@echo "Release artifacts in $(DIST_DIR)/"
@ls -lh $(DIST_DIR)/