#/bin/bash

# Define the array of packages
packages=(
"tari_dan_storage"
"tari_state_store_sqlite"
"tari_dan_p2p"
"tari_indexer_lib"
"tari_epoch_manager"
"tari_engine_types"
"tari_dan_engine"
"tari_template_builtin"
"tari_consensus"
"tari_comms_logging"
"tari_dan_common_types"
"tari_comms_rpc_state_sync"
"tari_wallet_daemon_client"
"tari_validator_node_client"
"tari_indexer_client"
"tari_base_node_client"
"tari_validator_node_cli"
"tari_signaling_server"
"tari_validator_node"
"tari_indexer"
"tari_scaffolder"
"tari_dan_wallet_cli"
"tari_dan_wallet_daemon"
"tari_dan_app_utilities"
)

sleep 300
# Loop through each package
for p in "${packages[@]}"; do
    #sleep 600
    # Step 1: Replace "%%NAME%%" with the current package name in Cargo.tmp
    sed "s/%%NAME%%/$p/" Cargo.tmp > Cargo.toml

    # Step 2: Run `cargo build`
    cargo publish --allow-dirty

    # Optional: Display a message indicating completion for each package
    echo "****** $p Done. *****"
    echo
    echo
    sleep 600
done

