-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
102 lines (81 loc) · 2.32 KB
/
justfile
File metadata and controls
102 lines (81 loc) · 2.32 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
94
95
96
97
98
99
100
101
102
# Build variables
VERSION := `git describe --tags --always --dirty`
COMMIT := `git rev-parse --short HEAD`
DATE := `date -u +"%Y-%m-%dT%H:%M:%SZ"`
# Binary name
BINARY_NAME := "gitclean"
# Build flags
LDFLAGS := "-s -w -X main.version=" + VERSION + " -X main.commit=" + COMMIT + " -X main.date=" + DATE
# Default recipe
default: test build
# Build the binary
build:
go build -ldflags "{{LDFLAGS}}" -o {{BINARY_NAME}} -v
# Clean build artifacts
clean:
go clean
rm -f {{BINARY_NAME}}
rm -rf dist/
# Run tests
test:
go test -v ./...
# Test the release process locally (dry run)
release-test:
goreleaser release --snapshot --clean
# Install dependencies
deps:
go mod download
go mod tidy
# Install goreleaser if not present
install-goreleaser:
#!/usr/bin/env bash
if ! which goreleaser > /dev/null; then
echo "Installing goreleaser..."
go install github.com/goreleaser/goreleaser@latest
fi
# Run locally built binary
run: build
./{{BINARY_NAME}}
# Install binary to /usr/local/bin
install: build
cp {{BINARY_NAME}} /usr/local/bin/
# Cross compile for different platforms
build-all:
#!/usr/bin/env bash
mkdir -p dist
# macOS
GOOS=darwin GOARCH=amd64 go build -ldflags "{{LDFLAGS}}" -o dist/{{BINARY_NAME}}-darwin-amd64
GOOS=darwin GOARCH=arm64 go build -ldflags "{{LDFLAGS}}" -o dist/{{BINARY_NAME}}-darwin-arm64
# Linux
GOOS=linux GOARCH=amd64 go build -ldflags "{{LDFLAGS}}" -o dist/{{BINARY_NAME}}-linux-amd64
GOOS=linux GOARCH=arm64 go build -ldflags "{{LDFLAGS}}" -o dist/{{BINARY_NAME}}-linux-arm64
# Windows
GOOS=windows GOARCH=amd64 go build -ldflags "{{LDFLAGS}}" -o dist/{{BINARY_NAME}}-windows-amd64.exe
# Check GoReleaser configuration
check:
goreleaser check
# Build a single target for testing
build-snapshot:
goreleaser build --snapshot --clean --single-target
# Show available commands
help:
@just --list
# Run with arguments (e.g., just run-with --help)
run-with *args: build
./{{BINARY_NAME}} {{args}}
# Format Go code
fmt:
go fmt ./...
# Run linting
lint:
golangci-lint run
# Run security scan
security:
gosec ./...
# Generate release notes
changelog:
git log --oneline --decorate --graph
# Tag a new version (e.g., just tag v1.0.0)
tag version:
git tag {{version}}
git push origin {{version}}