-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
93 lines (78 loc) · 2.72 KB
/
Makefile
File metadata and controls
93 lines (78 loc) · 2.72 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
85
86
87
88
89
90
91
92
93
.PHONY: build test lint clean release help dmg zip coverage integration-test act-test act-lint
BINARY_NAME=settingssentry
VERSION=$(shell git describe --tags --always --dirty)
LDFLAGS=-ldflags "-X main.Version=${VERSION}"
help:
@echo "Available commands:"
@echo " make build - Build the application"
@echo " make test - Run tests"
@echo " make integration-test - Run integration tests"
@echo " make coverage - Generate test coverage report"
@echo " make lint - Run linter"
@echo " make act-test - Run tests with act (GitHub Actions locally)"
@echo " make act-lint - Run linter with act (GitHub Actions locally)"
@echo " make clean - Remove build artifacts"
@echo " make release - Create a new release"
@echo " make dmg - Create a macOS DMG installer"
@echo " make zip - Create a zip archive"
@echo " make help - Show this help message"
build:
@echo "Temporarily renaming TestCommand.cfg..."
@mv configs/TestCommand.cfg configs/TestCommand.not_embed || true
@echo "Building..."
@go build ${LDFLAGS} -o ${BINARY_NAME} . ; \
EXIT_CODE=$$? ; \
echo "Renaming TestCommand.cfg back..." ; \
mv configs/TestCommand.not_embed configs/TestCommand.cfg || true ; \
exit $$EXIT_CODE
test:
go test -v -race ./...
integration-test:
go test -v -tags=integration ./...
coverage:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
lint:
@if ! command -v golangci-lint &> /dev/null; then \
echo "golangci-lint not found, installing..."; \
brew install golangci-lint; \
fi
golangci-lint run ./...
clean:
go clean
rm -f ${BINARY_NAME}
rm -rf dist/
rm -f *.dmg
rm -f *.zip
rm -f coverage.out
release:
@echo "Temporarily renaming TestCommand.cfg..."
@mv configs/TestCommand.cfg configs/TestCommand.not_embed || true
@echo "Building..."
@goreleaser release --snapshot --clean ; \
EXIT_CODE=$$? ; \
echo "Renaming TestCommand.cfg back..." ; \
mv configs/TestCommand.not_embed configs/TestCommand.cfg || true ; \
exit $$EXIT_CODE
dmg:
mkdir -p ./${BINARY_NAME}.app/Contents/MacOS
cp ${BINARY_NAME} ./${BINARY_NAME}.app/Contents/MacOS/
hdiutil create -volname "${BINARY_NAME}" -srcfolder ./${BINARY_NAME}.app -ov -format UDZO ${BINARY_NAME}.dmg
zip: build
zip -r ${BINARY_NAME}.zip ${BINARY_NAME} configs
install: build
cp ${BINARY_NAME} /usr/local/bin/
uninstall:
rm -f /usr/local/bin/${BINARY_NAME}
act-test:
@if ! command -v act &> /dev/null; then \
echo "act not found. Install it with: brew install act"; \
exit 1; \
fi
act push -j test
act-lint:
@if ! command -v act &> /dev/null; then \
echo "act not found. Install it with: brew install act"; \
exit 1; \
fi
act push -j lint