-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
145 lines (117 loc) · 3.36 KB
/
justfile
File metadata and controls
145 lines (117 loc) · 3.36 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# List all available commands
default:
just --list
# Build the project
build:
cargo build --workspace --all-features --all-targets
# Clean the build artifacts
clean:
cargo clean --verbose
# Linting
clippy:
cargo clippy --workspace --all-features --all-targets -- -D warnings
# Check formatting
check-fmt:
cargo +nightly fmt --all -- --check
# Fix formatting
fmt:
cargo +nightly fmt --all
# Test the project
test:
cargo test --workspace --all-features --all-targets
# Run all the checks
check:
just check-fmt
just clippy
just test
# Generate OpenAPI documentation
openapi:
cargo run --bin openapi-generator > openapi.json
# Initialize and update submodules (for first-time setup)
init-submodules:
git submodule update --init --recursive
# Update git submodules
update-submodules:
git submodule update --remote --merge
# Run all commend in the local environment
all:
just check
just build
just openapi
# Run the main program
run:
unset https_proxy http_proxy all_proxy && cargo run --bin stackclass-server
# Bump version in Cargo.toml (interactive)
bump-version:
#!/usr/bin/env bash
set -euo pipefail
# Show current version
current_version=$(grep -m1 '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
echo "Current version: $current_version"
# Prompt for new version
read -p "New version: " new_version
# Validate version format
if ! [[ "$new_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Version must be in format X.Y.Z (e.g., 0.1.0)"
exit 1
fi
echo ""
# Update Cargo.toml
sed -i '' -E \
"s/^version = \"[0-9]+\.[0-9]+\.[0-9]+\"/version = \"$new_version\"/" \
Cargo.toml
echo "Updated Cargo.toml"
# Run full validation
echo ""
echo "Running validation..."
just all
echo ""
echo "Version bump to $new_version completed! Run 'just release' to commit and push."
# Release current version (commit, tag, push)
release:
#!/usr/bin/env bash
set -euo pipefail
# Helper function for confirmation
confirm() {
read -p "$1 [y/N] " response
case "$response" in
[yY][eE][sS]|[yY]) return 0 ;;
*) return 1 ;;
esac
}
# Get current version from Cargo.toml
version=$(grep -m1 '^version = ' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
echo "=== Release v$version ==="
echo ""
# Step 1: Git add and commit
echo "=== [1/3] Git add and commit ==="
echo "Changes to be committed:"
git status --short
echo ""
if confirm "Run 'git add -A && git commit -m \"chore: bump version to $version\"'?"; then
git add -A
git commit -m "chore: bump version to $version"
echo ""
else
echo "Aborted at step 1/3."
exit 0
fi
# Step 2: Git tag
echo "=== [2/3] Git tag ==="
if confirm "Run 'git tag -m \"v$version\" v$version'?"; then
git tag -m "v$version" "v$version"
echo ""
else
echo "Aborted at step 2/3."
exit 0
fi
# Step 3: Push branch and tag
echo "=== [3/3] Push branch and tag ==="
if confirm "Run 'git push origin main v$version'?"; then
git push origin main "v$version"
echo ""
else
echo "Aborted at step 3/3."
exit 0
fi
echo "=== Release v$version completed successfully! ==="