-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
121 lines (100 loc) · 4.16 KB
/
justfile
File metadata and controls
121 lines (100 loc) · 4.16 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# kwelea — development tasks
# https://just.systems
default:
@just --list
binary_name := "kwelea"
build_dir := "bin"
version_file := "VERSION"
version := `cat {{version_file}} 2>/dev/null || git describe --tags --always 2>/dev/null || echo 'dev'`
commit := `git rev-parse --short HEAD 2>/dev/null || echo 'none'`
date := `date -u +%Y-%m-%dT%H:%M:%SZ`
ldflags := "-s -w -X main.version=" + version + " -X main.commit=" + commit + " -X main.date=" + date
# Build the kwelea binary
build:
@mkdir -p {{ build_dir }}
go build -ldflags="{{ ldflags }}" -o {{ build_dir }}/{{ binary_name }} .
# 🌎 Build for all supported platforms
build-all:
@mkdir -p {{ build_dir }}
@for os in linux darwin; do \
for arch in amd64 arm64; do \
echo "🔨 Building {{ binary_name }}-${os}-${arch}..."; \
GOOS=$os GOARCH=$arch go build -ldflags="{{ ldflags }}" -o {{ build_dir }}/{{ binary_name }}-${os}-${arch} .; \
done; \
done
@echo "🔨 Building {{ binary_name }}-windows-amd64.exe..."
@GOOS=windows GOARCH=amd64 go build -ldflags="{{ ldflags }}" -o {{ build_dir }}/{{ binary_name }}-windows-amd64.exe .
@echo "✅ All platforms built in {{ build_dir }}/"
# Install kwelea globally
install:
go install .
# Run all tests
test:
@echo "🧪 Running tests..."
gotestsum --format=pkgname-and-test-fails ./...
# Run tests with verbose output
test-v:
go test -v ./...
# 📊 Run tests with coverage report
test-coverage:
@echo "📊 Generating coverage report..."
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "✅ Coverage report generated: coverage.html"
# 🧹 Format all Go source files
fmt:
@echo "🧹 Formatting code..."
go fmt ./...
# 🔎 Vet the code for potential bugs
vet:
@echo "🔎 Vetting code..."
go vet ./...
# ✅ Run formatter and vet sequentially
check: fmt vet
# Build the kwelea docs with kwelea itself (dogfood)
docs: build
{{ build_dir }}/{{ binary_name }} build
# Serve the kwelea docs locally (dogfood)
serve: build
{{ build_dir }}/{{ binary_name }} serve
# Remove build artifacts
clean:
rm -rf {{ build_dir }}/
rm -rf site/
# Download/refresh self-hosted font files into assets/fonts/
download-fonts:
mkdir -p assets/fonts
curl -sL "https://fonts.gstatic.com/s/ibmplexmono/v20/-F63fjptAgt5VM-kVkqdyU8n1i8q1w.woff2" -o assets/fonts/ibm-plex-mono-400.woff2
curl -sL "https://fonts.gstatic.com/s/ibmplexmono/v20/-F6qfjptAgt5VM-kVkqdyU8n3twJwlBFgg.woff2" -o assets/fonts/ibm-plex-mono-500.woff2
curl -sL "https://fonts.gstatic.com/s/ibmplexsans/v23/zYXzKVElMYYaJe8bpLHnCwDKr932-G7dytD-Dmu1syxeKYY.woff2" -o assets/fonts/ibm-plex-sans.woff2
curl -sL "https://fonts.gstatic.com/s/lora/v37/0QIvMX1D_JOuMwr7Iw.woff2" -o assets/fonts/lora.woff2
curl -sL "https://fonts.gstatic.com/s/lora/v37/0QI8MX1D_JOuMw_hLdO6T2wV9KnW-MoFoq92nA.woff2" -o assets/fonts/lora-italic.woff2
@echo "fonts downloaded to assets/fonts/"
# 📦 Create a new release with commit-and-tag-version (requires global installation: npm i -g commit-and-tag-version) (args optional, e.g. --release-as 0.1.0)
release *ARGS:
#!/usr/bin/env sh
if ! command -v commit-and-tag-version > /dev/null 2>&1; then
echo "Error: commit-and-tag-version command not found."
echo "Please install it globally with: npm i -g commit-and-tag-version"
exit 1
fi
commit-and-tag-version {{ ARGS }}
# [🤖 CI task] extract content from CHANGELOG.md for use in Gitlab/Github Releases
release-notes:
#!/usr/bin/env bash
set -euo pipefail
changelog_path="{{ invocation_directory() }}/CHANGELOG.md"
release_notes_path="{{ invocation_directory() }}/../LATEST_RELEASE_NOTES.md"
# Create header for release notes
echo "## What's changed in this release" > "$release_notes_path"
# Extract content between first and second level 2 heading
awk '/^## /{
if (count == 0) {
count = 1
next
} else if (count == 1) {
exit
}
}
count == 1 { print }' "$changelog_path" >> "$release_notes_path"
echo "Release notes extracted to $release_notes_path"