-
Notifications
You must be signed in to change notification settings - Fork 0
/
justfile
105 lines (86 loc) · 2.85 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
set dotenv-load
# List available commands
default:
@just --list
# Build the CLI tool
build:
go build -o bin/kubelog main.go
# Run tests
test:
go test ./...
# Build with version information
build-version:
#!/usr/bin/env bash
VERSION=$(git describe --tags --always --dirty)
COMMIT_HASH=$(git rev-parse --short HEAD)
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
go build -ldflags "-X github.com/dantech2000/kubelog/lib.commitHash=${COMMIT_HASH} -X github.com/dantech2000/kubelog/lib.buildDate=${BUILD_DATE}" -o bin/kubelog main.go
# Cross-compile for multiple platforms
cross-compile:
#!/usr/bin/env bash
VERSION=$(git describe --tags --always --dirty)
COMMIT_HASH=$(git rev-parse --short HEAD)
BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS="-X github.com/dantech2000/kubelog/lib.commitHash=${COMMIT_HASH} -X github.com/dantech2000/kubelog/lib.buildDate=${BUILD_DATE}"
GOOS=linux GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o bin/kubelog-linux-amd64 main.go
GOOS=darwin GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o bin/kubelog-darwin-amd64 main.go
GOOS=windows GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o bin/kubelog-windows-amd64.exe main.go
# Run linter
lint:
golangci-lint run
# Format code
fmt:
go fmt ./...
# Clean build artifacts
clean:
rm -rf bin/*
# Install dependencies
deps:
go mod tidy
go mod verify
# Run the CLI tool
run *ARGS:
go run main.go {{ ARGS }}
# Create a new release with the specified version
release version:
#!/usr/bin/env bash
echo "Attempting to create release with version: {{version}}"
if [[ ! "{{version}}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version must be in the format v0.0.0"
exit 1
fi
if git rev-parse {{version}} >/dev/null 2>&1; then
echo "Error: Tag {{version}} already exists."
echo "To force update the tag, use: just release-force {{version}}"
exit 1
fi
echo "Version format valid, creating tag..."
git tag -a {{version}} -m "Release {{version}}"
git push origin {{version}}
# Force update an existing release version
release-force version:
#!/usr/bin/env bash
echo "Force updating release version: {{version}}"
if [[ ! "{{version}}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version must be in the format v0.0.0"
exit 1
fi
git tag -fa {{version}} -m "Release {{version}}"
git push origin {{version}} --force
# Generate and update changelog
changelog:
git-chglog -o CHANGELOG.md
# Run goreleaser to create a new release
release-goreleaser:
#!/usr/bin/env bash
if [ ! -f .env ]; then
echo "Error: .env file not found"
exit 1
fi
set -a
source .env
set +a
goreleaser release
# Build and run in one step
build-and-run *ARGS: build
./bin/kubelog {{ ARGS }}