-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpublish-all-plugins-now.sh
More file actions
executable file
·127 lines (105 loc) · 3.43 KB
/
publish-all-plugins-now.sh
File metadata and controls
executable file
·127 lines (105 loc) · 3.43 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
#!/usr/bin/env bash
set -o pipefail
# Publish ALL plugin crates to crates.io with rate-limit handling
# Prerequisites: elizaos, elizaos-sweagent, computeruse-rs already published
WORKSPACE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PLUGINS_DIR="${WORKSPACE_DIR}/plugins"
DELAY_BETWEEN=10 # seconds between publishes to avoid rate limits
PUBLISHED=()
FAILED=()
SKIPPED=()
publish_plugin() {
local plugin_name="$1"
local dir="${PLUGINS_DIR}/${plugin_name}/rust"
if [[ ! -f "${dir}/Cargo.toml" ]]; then
return
fi
local crate_name
crate_name=$(grep '^name' "${dir}/Cargo.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')
local version
version=$(grep '^version' "${dir}/Cargo.toml" | head -1 | sed 's/.*"\(.*\)".*/\1/')
printf " %-50s " "${crate_name}@${version}"
# Temporarily rewrite path deps for publishing
cp "${dir}/Cargo.toml" "${dir}/Cargo.toml.orig"
# Rewrite all path deps to version-only
perl -i -pe '
s|elizaos = \{ version = "[^"]*", path = "[^"]*"[^}]*\}|elizaos = "2.0.0"|g;
s|elizaos = \{ path = "[^"]*"[^}]*\}|elizaos = "2.0.0"|g;
s|elizaos-plugin-mcp = \{ version = "[^"]*", path = "[^"]*"[^}]*\}|elizaos-plugin-mcp = "2.0.0"|g;
s|computeruse-rs = \{ version = "[^"]*", path = "[^"]*"[^}]*\}|computeruse-rs = "2.0.0"|g;
s|computeruse-rs = \{ package = "computeruse-rs", version = "[^"]*", path = "[^"]*"[^}]*\}|computeruse-rs = "2.0.0"|g;
' "${dir}/Cargo.toml"
local output
local rc
local retries=0
while true; do
output=$(cd "$dir" && cargo publish --allow-dirty --no-verify 2>&1)
rc=$?
if [[ $rc -eq 0 ]]; then
echo "PUBLISHED"
PUBLISHED+=("${crate_name}")
break
fi
if echo "$output" | grep -q "already uploaded\|already exists"; then
echo "ALREADY"
SKIPPED+=("${crate_name} (already)")
break
fi
if echo "$output" | grep -q "429\|Too Many Requests\|rate limit"; then
retries=$((retries + 1))
if [[ $retries -gt 3 ]]; then
echo "RATE-LIMITED (giving up)"
FAILED+=("${crate_name}: rate limited after 3 retries")
break
fi
echo -n "RATE-LIMITED (retry ${retries}, waiting 60s)... "
sleep 60
continue
fi
# Other error
local err
err=$(echo "$output" | grep "error" | head -1)
echo "FAILED"
FAILED+=("${crate_name}: ${err}")
break
done
# Restore original Cargo.toml
mv "${dir}/Cargo.toml.orig" "${dir}/Cargo.toml"
sleep "$DELAY_BETWEEN"
}
echo ""
echo "================================================================"
echo " Publishing ALL plugin crates to crates.io"
echo " Delay between publishes: ${DELAY_BETWEEN}s"
echo "================================================================"
echo ""
for dir in "${PLUGINS_DIR}"/plugin-*/rust; do
if [[ -d "$dir" && -f "${dir}/Cargo.toml" ]]; then
plugin_name=$(basename "$(dirname "$dir")")
publish_plugin "$plugin_name"
fi
done
echo ""
echo "================================================================"
echo " SUMMARY"
echo "================================================================"
echo ""
echo " Published: ${#PUBLISHED[@]}"
echo " Skipped: ${#SKIPPED[@]}"
echo " Failed: ${#FAILED[@]}"
echo ""
if [[ ${#PUBLISHED[@]} -gt 0 ]]; then
echo " PUBLISHED:"
for p in "${PUBLISHED[@]}"; do
echo " + $p"
done
echo ""
fi
if [[ ${#FAILED[@]} -gt 0 ]]; then
echo " FAILURES:"
for f in "${FAILED[@]}"; do
echo " X $f"
done
echo ""
exit 1
fi