-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (39 loc) · 1.65 KB
/
Makefile
File metadata and controls
49 lines (39 loc) · 1.65 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
.PHONY: build run test clean install install-remote release
# Ensure go is found (common install paths: Homebrew, /usr/local/go)
export PATH := /opt/homebrew/bin:/usr/local/go/bin:/usr/local/bin:$(PATH)
BINARY_NAME := cosmos
BUILD_DIR := bin
RELEASE_DIR := release
MAIN_PATH := ./cmd/cosmos
# Full module path for "install like Docker" (go install from anywhere)
INSTALL_PATH := github.com/cosmos-toolkit/cli/cmd/cosmos
# Version for release tarballs (set via: make release VERSION=1.0.0)
VERSION ?= dev
build:
go build -o $(BUILD_DIR)/$(BINARY_NAME) $(MAIN_PATH)
run: build
$(BUILD_DIR)/$(BINARY_NAME) $(ARGS)
test:
go test ./...
clean:
rm -rf $(BUILD_DIR) $(RELEASE_DIR)
# Install binary to $HOME/go/bin (or GOPATH/bin). Requires that dir in PATH.
install:
go install $(MAIN_PATH)
# Same as install but fetches from remote (no clone needed). For README/CI.
install-remote:
go install $(INSTALL_PATH)@latest
# Build binaries for all platforms (for GitHub Releases). Creates release/cosmos-<VERSION>-<os>-<arch>.tar.gz
# Usage: make release VERSION=1.0.0
release:
@mkdir -p $(RELEASE_DIR)
@for goos in darwin linux; do \
for goarch in amd64 arm64; do \
GOOS=$$goos GOARCH=$$goarch go build -o $(RELEASE_DIR)/$(BINARY_NAME) $(MAIN_PATH) && \
(cd $(RELEASE_DIR) && tar -czf $(BINARY_NAME)-$(VERSION)-$$goos-$$goarch.tar.gz $(BINARY_NAME) && rm -f $(BINARY_NAME)); \
done; \
done
@GOOS=windows GOARCH=amd64 go build -o $(RELEASE_DIR)/$(BINARY_NAME).exe $(MAIN_PATH)
@(cd $(RELEASE_DIR) && zip -q $(BINARY_NAME)-$(VERSION)-windows-amd64.zip $(BINARY_NAME).exe && rm -f $(BINARY_NAME).exe)
@echo "Release artifacts in $(RELEASE_DIR)/"
@ls -la $(RELEASE_DIR)/