-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (63 loc) · 2.39 KB
/
Makefile
File metadata and controls
84 lines (63 loc) · 2.39 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
BINARY := slck
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE := $(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
LDFLAGS := -ldflags "-s -w \
-X github.com/open-cli-collective/slack-chat-api/internal/version.Version=$(VERSION) \
-X github.com/open-cli-collective/slack-chat-api/internal/version.Commit=$(COMMIT) \
-X github.com/open-cli-collective/slack-chat-api/internal/version.Date=$(DATE)"
DIST_DIR = dist
.PHONY: all build test test-cover test-short lint fmt deps verify clean release checksums install uninstall
all: build
build:
go build $(LDFLAGS) -o bin/$(BINARY) ./cmd/slck
test:
go test -v -race ./...
test-cover:
go test -v -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
test-short:
go test -v -short ./...
lint:
golangci-lint run
fmt:
go fmt ./...
goimports -local github.com/open-cli-collective/slack-chat-api -w .
deps:
go mod download
go mod tidy
verify:
go mod verify
clean:
rm -rf bin/ $(DIST_DIR)/ coverage.out coverage.html $(BINARY)
# Build for all platforms
release: clean
mkdir -p $(DIST_DIR)
# macOS ARM64
GOOS=darwin GOARCH=arm64 go build $(LDFLAGS) -o $(DIST_DIR)/$(BINARY) ./cmd/slck
tar -czvf $(DIST_DIR)/$(BINARY)_$(VERSION)_darwin_arm64.tar.gz -C $(DIST_DIR) $(BINARY)
rm $(DIST_DIR)/$(BINARY)
# macOS AMD64
GOOS=darwin GOARCH=amd64 go build $(LDFLAGS) -o $(DIST_DIR)/$(BINARY) ./cmd/slck
tar -czvf $(DIST_DIR)/$(BINARY)_$(VERSION)_darwin_amd64.tar.gz -C $(DIST_DIR) $(BINARY)
rm $(DIST_DIR)/$(BINARY)
# Linux ARM64
GOOS=linux GOARCH=arm64 go build $(LDFLAGS) -o $(DIST_DIR)/$(BINARY) ./cmd/slck
tar -czvf $(DIST_DIR)/$(BINARY)_$(VERSION)_linux_arm64.tar.gz -C $(DIST_DIR) $(BINARY)
rm $(DIST_DIR)/$(BINARY)
# Linux AMD64
GOOS=linux GOARCH=amd64 go build $(LDFLAGS) -o $(DIST_DIR)/$(BINARY) ./cmd/slck
tar -czvf $(DIST_DIR)/$(BINARY)_$(VERSION)_linux_amd64.tar.gz -C $(DIST_DIR) $(BINARY)
rm $(DIST_DIR)/$(BINARY)
@echo "Release archives created in $(DIST_DIR)/"
@ls -la $(DIST_DIR)/
# Generate SHA256 checksums for Homebrew formula
checksums:
@echo "SHA256 checksums for Homebrew formula:"
@for f in $(DIST_DIR)/*.tar.gz; do \
echo "$$(shasum -a 256 $$f | cut -d' ' -f1) $$(basename $$f)"; \
done
install: build
install -m 755 bin/$(BINARY) /usr/local/bin/
uninstall:
rm -f /usr/local/bin/$(BINARY)