Skip to content

Commit 218ecca

Browse files
committed
Add publish script
1 parent 6fbda80 commit 218ecca

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

scripts/publish-all-crates.sh

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Colors for output
6+
RED='\033[0;31m'
7+
GREEN='\033[0;32m'
8+
YELLOW='\033[1;33m'
9+
NC='\033[0m' # No Color
10+
11+
# Default to dry run
12+
DRY_RUN=true
13+
14+
# Parse command line arguments
15+
while [[ $# -gt 0 ]]; do
16+
case $1 in
17+
--publish|--real|--force)
18+
DRY_RUN=false
19+
shift
20+
;;
21+
--dry-run)
22+
DRY_RUN=true
23+
shift
24+
;;
25+
-h|--help)
26+
echo "Usage: $0 [--publish|--real|--force] [--dry-run]"
27+
echo ""
28+
echo "Options:"
29+
echo " --publish, --real, --force Actually publish crates (default is dry-run)"
30+
echo " --dry-run Only show what would be published (default)"
31+
echo " -h, --help Show this help message"
32+
exit 0
33+
;;
34+
*)
35+
echo "Unknown option $1"
36+
echo "Use --help for usage information"
37+
exit 1
38+
;;
39+
esac
40+
done
41+
42+
# Get script directory
43+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
44+
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
45+
46+
echo -e "${YELLOW}Publishing all crates in workspace...${NC}"
47+
if [ "$DRY_RUN" = true ]; then
48+
echo -e "${YELLOW}Running in DRY RUN mode. Use --publish to actually publish.${NC}"
49+
else
50+
echo -e "${RED}REAL PUBLISH MODE - This will actually publish crates!${NC}"
51+
read -p "Are you sure you want to continue? (y/N) " -n 1 -r
52+
echo
53+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
54+
echo "Aborted."
55+
exit 1
56+
fi
57+
fi
58+
59+
cd "$PROJECT_ROOT"
60+
61+
# Define crates in dependency order (must be published in this order)
62+
CRATE_DIRS=(
63+
"crates/wasmind_llm_types"
64+
"crates/wasmind_config"
65+
"crates/wasmind_actor_bindings"
66+
"crates/wasmind_actor_utils_macros"
67+
"crates/wasmind_actor_utils_common_messages"
68+
"crates/wasmind_actor_utils"
69+
"crates/wasmind_actor_loader"
70+
"crates/wasmind"
71+
"crates/wasmind_cli"
72+
)
73+
74+
# Verify all crates exist
75+
echo -e "${GREEN}Crates to publish (in dependency order):${NC}"
76+
for crate_dir in "${CRATE_DIRS[@]}"; do
77+
if [ ! -f "$crate_dir/Cargo.toml" ]; then
78+
echo -e "${RED}Error: $crate_dir/Cargo.toml not found${NC}"
79+
exit 1
80+
fi
81+
crate_name=$(grep "^name" "$crate_dir/Cargo.toml" | head -1 | sed 's/name = "\(.*\)"/\1/')
82+
echo " - $crate_name ($crate_dir)"
83+
done
84+
85+
echo ""
86+
87+
# Publish each crate in dependency order
88+
for crate_dir in "${CRATE_DIRS[@]}"; do
89+
crate_name=$(grep "^name" "$crate_dir/Cargo.toml" | head -1 | sed 's/name = "\(.*\)"/\1/')
90+
91+
echo -e "${YELLOW}Processing $crate_name...${NC}"
92+
93+
cd "$PROJECT_ROOT/$crate_dir"
94+
95+
if [ "$DRY_RUN" = true ]; then
96+
echo " Running: cargo publish --dry-run"
97+
if cargo publish --dry-run; then
98+
echo -e " ${GREEN}$crate_name would publish successfully${NC}"
99+
else
100+
echo -e " ${RED}$crate_name would fail to publish${NC}"
101+
fi
102+
else
103+
echo " Running: cargo publish"
104+
if cargo publish; then
105+
echo -e " ${GREEN}$crate_name published successfully${NC}"
106+
else
107+
echo -e " ${RED}$crate_name failed to publish${NC}"
108+
echo " Continuing with remaining crates..."
109+
fi
110+
# Add a small delay between publishes to avoid rate limiting
111+
sleep 2
112+
fi
113+
114+
cd "$PROJECT_ROOT"
115+
echo ""
116+
done
117+
118+
if [ "$DRY_RUN" = true ]; then
119+
echo -e "${GREEN}Dry run completed. Use --publish to actually publish crates.${NC}"
120+
else
121+
echo -e "${GREEN}Publishing completed!${NC}"
122+
fi

0 commit comments

Comments
 (0)