|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e # Exit immediately if a command exits with a non-zero status |
| 4 | + |
| 5 | +# Function to publish a crate and wait for it to be available |
| 6 | +publish_crate() { |
| 7 | + local crate_name="$1" |
| 8 | + echo "Publishing $crate_name..." |
| 9 | + |
| 10 | + # Publish the crate |
| 11 | + cargo publish -p "$crate_name" --registry crates-io |
| 12 | + |
| 13 | + # Wait for the crate to be available on crates.io |
| 14 | + echo "Waiting for $crate_name to be available on crates.io..." |
| 15 | + sleep 3 # Initial delay to give crates.io time to process |
| 16 | + |
| 17 | + # You might need to adjust this timeout depending on crates.io processing time |
| 18 | + local max_attempts=10 |
| 19 | + local attempt=1 |
| 20 | + |
| 21 | + while [ $attempt -le $max_attempts ]; do |
| 22 | + echo "Checking if $crate_name is available (attempt $attempt/$max_attempts)..." |
| 23 | + |
| 24 | + # Try to fetch the crate info from crates.io API |
| 25 | + if curl -s "https://crates.io/api/v1/crates/$crate_name" | grep -q "\"name\":\"$crate_name\""; then |
| 26 | + echo "$crate_name is now available on crates.io!" |
| 27 | + return 0 |
| 28 | + fi |
| 29 | + |
| 30 | + echo "$crate_name not yet available, waiting..." |
| 31 | + sleep 3 |
| 32 | + ((attempt++)) |
| 33 | + done |
| 34 | + |
| 35 | + echo "Warning: Timed out waiting for $crate_name to appear on crates.io" |
| 36 | + echo "Continuing with the next crate, but there might be dependency issues." |
| 37 | + return 1 |
| 38 | +} |
| 39 | + |
| 40 | +# Main script execution |
| 41 | +echo "Starting AIScript crates publication process..." |
| 42 | + |
| 43 | +# Publish crates in dependency order |
| 44 | +publish_crate "aiscript-lexer" |
| 45 | +publish_crate "aiscript-directive" |
| 46 | +publish_crate "aiscript-vm" |
| 47 | +publish_crate "aiscript-runtime" |
| 48 | +publish_crate "aiscript" |
| 49 | + |
| 50 | +echo "Publication process completed!" |
0 commit comments