-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
103 lines (86 loc) · 2.82 KB
/
justfile
File metadata and controls
103 lines (86 loc) · 2.82 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
103
prog := "getgo"
# Default recipe to show available commands
default:
@just --list
# Build flags for optimized binaries
build_flags := "-ldflags='-s -w' -trimpath"
# Build for the current platform
build:
go build {{build_flags}} -o {{prog}}
# Clean build artifacts
clean:
rm -rf dist
rm -f {{prog}} {{prog}}.exe
# Create distribution directory
create-dist:
mkdir -p dist
# Build for a specific platform and architecture
build-for os arch:
@echo "Building for {{os}} ({{arch}})..."
@mkdir -p dist
@if [ "{{os}}" = "windows" ]; then \
GOOS={{os}} GOARCH={{arch}} go build {{build_flags}} -o dist/{{prog}}-{{os}}-{{arch}}.exe; \
else \
GOOS={{os}} GOARCH={{arch}} go build {{build_flags}} -o dist/{{prog}}-{{os}}-{{arch}}; \
fi
@if [ "{{os}}" = "windows" ]; then \
echo "✓ Built dist/{{prog}}-{{os}}-{{arch}}.exe"; \
else \
echo "✓ Built dist/{{prog}}-{{os}}-{{arch}}"; \
fi
# Build for all platforms (linux, macos, windows) and architectures (amd64, arm64)
build-all: clean create-dist
just build-for linux amd64
just build-for linux arm64
just build-for darwin amd64
just build-for darwin arm64
just build-for windows amd64
just build-for windows arm64
@echo "All builds completed successfully!"
@ls -la dist/
# Build for Linux amd64
build-linux-amd64:
@just build-for linux amd64
# Build for Linux arm64
build-linux-arm64:
@just build-for linux arm64
# Build for macOS amd64
build-macos-amd64:
@just build-for darwin amd64
# Build for macOS arm64
build-macos-arm64:
@just build-for darwin arm64
# Build for Windows amd64
build-windows-amd64:
@just build-for windows amd64
# Build for Windows arm64
build-windows-arm64:
@just build-for windows arm64
# Create archive for a specific build
create-archive os arch:
@echo "Creating archive for {{os}}/{{arch}} with documentation..."
@cp README.md dist/
@if [ -f LICENSE ]; then cp LICENSE dist/; fi
@if [ "{{os}}" = "windows" ]; then \
cd dist && zip {{prog}}-{{os}}-{{arch}}.zip {{prog}}-{{os}}-{{arch}}.exe README.md $([ -f LICENSE ] && echo "LICENSE"); \
else \
cd dist && tar -czf {{prog}}-{{os}}-{{arch}}.tar.gz {{prog}}-{{os}}-{{arch}} README.md $([ -f LICENSE ] && echo "LICENSE"); \
fi
@rm -f dist/README.md dist/LICENSE 2>/dev/null
@echo "✓ Archive created for {{os}}/{{arch}}"
# Create release archives
package: build-all
@echo "Creating release archives..."
just create-archive linux amd64
just create-archive linux arm64
just create-archive darwin amd64
just create-archive darwin arm64
just create-archive windows amd64
just create-archive windows arm64
@echo "✓ Created release archives in dist/"
# Run tests
test:
go test -v ./...
# Install locally
install: build
go install