-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (47 loc) · 1.79 KB
/
Makefile
File metadata and controls
58 lines (47 loc) · 1.79 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
BUILD_DIR := ./build
BINARY := inline-cli
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
LDFLAGS := -ldflags "-s -w -X main.version=$(VERSION)"
# Cross-compilation targets: OS_ARCH pairs
PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64
.PHONY: build test lint clean install release release-binaries release-tarballs checksums
build:
go build $(LDFLAGS) -o $(BUILD_DIR)/$(BINARY) ./cmd/inline-cli
test:
go test -race -cover ./...
lint:
go vet ./...
clean:
rm -rf $(BUILD_DIR)
install: build
cp $(BUILD_DIR)/$(BINARY) $(GOPATH)/bin/ 2>/dev/null || cp $(BUILD_DIR)/$(BINARY) ~/go/bin/
# Build binaries for all platforms
release-binaries:
@for platform in $(PLATFORMS); do \
os=$${platform%/*}; \
arch=$${platform#*/}; \
output=$(BUILD_DIR)/$(BINARY)_$(VERSION)_$${os}_$${arch}/$(BINARY); \
echo "building $$os/$$arch..."; \
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 go build $(LDFLAGS) -o $$output ./cmd/inline-cli || exit 1; \
done
# Package each binary into a tarball matching install.sh's expected naming
release-tarballs: release-binaries
@for platform in $(PLATFORMS); do \
os=$${platform%/*}; \
arch=$${platform#*/}; \
dir=$(BUILD_DIR)/$(BINARY)_$(VERSION)_$${os}_$${arch}; \
tarball=$(BUILD_DIR)/$(BINARY)_$(VERSION)_$${os}_$${arch}.tar.gz; \
echo "packaging $$tarball..."; \
tar -czf $$tarball -C $$dir $(BINARY); \
done
# Generate checksums for all tarballs
checksums: release-tarballs
@cd $(BUILD_DIR) && shasum -a 256 $(BINARY)_$(VERSION)_*.tar.gz > checksums.txt
@echo "checksums written to $(BUILD_DIR)/checksums.txt"
# Full release: binaries + tarballs + checksums
release: checksums
@echo ""
@echo "release artifacts in $(BUILD_DIR)/:"
@ls -lh $(BUILD_DIR)/$(BINARY)_$(VERSION)_*.tar.gz
@echo ""
@cat $(BUILD_DIR)/checksums.txt