-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
69 lines (57 loc) · 2.03 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
59
60
61
62
63
64
65
66
67
68
69
GO_INSTALLED := $(shell command -v go version)
GO_VERSION := 1.22
GORELEASER_EXISTS := $(shell command -v goreleaser version)
INSTALL_GORELEASER := go install github.com/goreleaser/goreleaser/v2@latest
# Linux setup
GO_TARBALL := https://golang.org/dl/go$(GO_VERSION).linux-amd64.tar.gz
LINUX_INSTALL_DIR := /usr/local
# Try to install Go on windows if it doesn't exist
install-go-windows:
@if [ -z "$(GO_INSTALLED)" ]; then \
echo "Go is not installed. Installing now..."; \
choco install golang --version $(GO_VERSION) -y; \
if [ $$? -ne 0 ]; then \
echo "Failed to install Golang. Please install it manually."; \
exit 1; \
fi \
fi
# Try to install Go on linux if it doesn't exist (partially tested)
install-go-linux:
@if [ -z "$(GO_INSTALLED)" ]; then \
echo "Go not found. Installing Go $(GO_VERSION)..."; \
curl -L $(GO_TARBALL) | sudo tar -C $(LINUX_INSTALL_DIR) -xzf; \
if [ $$? -ne 0 ]; then \
echo "Failed to install Golang. Please install it manually."; \
exit 1; \
fi \
fi
# Try to install go on macos if it doesn't exist (not tested)
install-go-macos:
@if [ -z "$(GO_INSTALLED)" ]; then \
echo "Go not found. Installing Go $(GO_VERSION)..."; \
brew install golang@$(GO_VERSION); \
if [ $$? -ne 0 ]; then \
echo "Failed to install Golang. Please install it manually."; \
exit 1; \
fi \
fi
# Check if GoReleaser is installed
install-goreleaser:
@if [ -z "$(GORELEASER_EXISTS)" ]; then \
echo "GoReleaser is not installed. Installing..."; \
$(INSTALL_GORELEASER); \
if [ $$? -ne 0 ]; then \
echo "Failed to install GoReleaser. Please install it manually."; \
exit 1; \
fi \
fi
setup-windows: install-go-windows install-goreleaser
@echo "You're are all set!"
setup-linux: install-go-linux install-goreleaser
@echo You're all set!
setup-macos: install-go-macos install-goreleaser
@echo You're all set!
dev:
goreleaser release --snapshot --clean --config .goreleaser.dev.yml
snapshot:
goreleaser release --snapshot --clean