-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjustfile
90 lines (76 loc) · 2.32 KB
/
justfile
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
# Default recipe to display help information
default:
@just --list
# Ensure bin directory exists
_ensure-bin:
mkdir -p bin
# Build the kubectl plugin
build: _ensure-bin
#!/usr/bin/env bash
set -euo pipefail
echo "Building kubectl-finalize..."
CGO_ENABLED=0 go build -ldflags="-s -w" -o bin/kubectl-finalize ./cmd/kubectl-finalize
echo "✅ Build successful: bin/kubectl-finalize"
# Install the plugin to /usr/local/bin
install: build
#!/usr/bin/env bash
set -euo pipefail
echo "Installing kubectl-finalize to /usr/local/bin..."
sudo install -m 755 bin/kubectl-finalize /usr/local/bin/
echo "✅ Plugin installed successfully! You can now use 'kubectl finalize'"
# Development build and run
dev *ARGS: _ensure-bin
#!/usr/bin/env bash
set -euo pipefail
go run ./cmd/kubectl-finalize {{ARGS}}
# Remove the installed plugin
uninstall:
@echo "Removing kubectl-finalize from /usr/local/bin..."
@sudo rm -f /usr/local/bin/kubectl-finalize
@echo "Plugin uninstalled successfully!"
# Run tests
test:
go test -v ./...
# Clean build artifacts
clean:
rm -rf bin/
go clean
# Format code
fmt:
go fmt ./...
# Run linter
lint:
golangci-lint run
# Build for multiple platforms
build-all:
#!/usr/bin/env bash
platforms=("linux/amd64" "darwin/amd64" "darwin/arm64" "windows/amd64")
for platform in "${platforms[@]}"; do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name=bin/kubectl-finalize
if [ $GOOS = "windows" ]; then
output_name+='.exe'
fi
output_name+="-${GOOS}-${GOARCH}"
echo "Building for $GOOS/$GOARCH..."
CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w" -o $output_name ./cmd/kubectl-finalize
echo "✅ Built $output_name"
done
echo "✅ All platforms built successfully!"
# Create a new release
release VERSION:
#!/usr/bin/env bash
echo "Creating release v{{VERSION}}..."
git tag -a "v{{VERSION}}" -m "Release v{{VERSION}}"
git push origin "v{{VERSION}}"
just build-all
# Setup development environment
setup:
go mod download
go mod tidy
mkdir -p bin
# Run the plugin with arguments (for development)
run *ARGS:
go run ./cmd/kubectl-finalize {{ARGS}}