Skip to content

Commit b65aaca

Browse files
committed
ci: crate publish improvements
1 parent 75b57b7 commit b65aaca

File tree

2 files changed

+76
-46
lines changed

2 files changed

+76
-46
lines changed

.github/workflows/canary.yml

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,12 +474,46 @@ jobs:
474474
- name: Publish crates
475475
env:
476476
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
477+
VERSION: ${{ needs.version.outputs.version }}
477478
run: |
478-
for crate in inferadb-ledger-types inferadb-ledger-store inferadb-ledger-state inferadb-ledger-proto inferadb-ledger-raft inferadb-ledger-sdk; do
479+
# Strip build metadata for crates.io (e.g., 0.1.0-dev.20260201.123+abc1234 → 0.1.0-dev.20260201.123)
480+
CRATE_VERSION="${VERSION%+*}"
481+
482+
# Wait for a crate version to appear in the crates.io index.
483+
# Polls every 10s for up to 5 minutes before failing.
484+
wait_for_crate() {
485+
local crate="$1"
486+
local version="$2"
487+
local max_attempts=30
488+
local attempt=0
489+
490+
echo "Waiting for ${crate}@${version} to be indexed on crates.io..."
491+
while [ $attempt -lt $max_attempts ]; do
492+
if cargo search "${crate}" --limit 1 2>/dev/null | grep -q "^${crate} = \"${version}\""; then
493+
echo "${crate}@${version} is now available"
494+
return 0
495+
fi
496+
attempt=$((attempt + 1))
497+
echo " Attempt ${attempt}/${max_attempts} — not yet indexed, retrying in 10s..."
498+
sleep 10
499+
done
500+
501+
echo "ERROR: Timed out waiting for ${crate}@${version} to be indexed after $((max_attempts * 10))s"
502+
return 1
503+
}
504+
505+
CRATES=(inferadb-ledger-types inferadb-ledger-store inferadb-ledger-state inferadb-ledger-proto inferadb-ledger-raft inferadb-ledger-sdk)
506+
LAST_INDEX=$(( ${#CRATES[@]} - 1 ))
507+
508+
for i in "${!CRATES[@]}"; do
509+
crate="${CRATES[$i]}"
479510
echo "Publishing ${crate}..."
480511
cargo publish -p "${crate}" --token "$CARGO_REGISTRY_TOKEN" --allow-dirty
481-
echo "Waiting for crates.io to index..."
482-
sleep 45
512+
513+
# Wait for indexing before publishing the next crate (skip for last crate)
514+
if [ "$i" -lt "$LAST_INDEX" ]; then
515+
wait_for_crate "${crate}" "${CRATE_VERSION}"
516+
fi
483517
done
484518
485519
# Clean up old canary releases to avoid clutter

.github/workflows/release.yml

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -469,49 +469,45 @@ jobs:
469469
uses: rust-lang/crates-io-auth-action@b7e9a28eded4986ec6b1fa40eeee8f8f165559ec # v1.0.3
470470
id: auth
471471

472-
# Publish crates in dependency order with delays for crates.io indexing
473-
- name: Publish inferadb-ledger-types
472+
# Publish crates in dependency order, polling crates.io index between each
473+
- name: Publish crates
474474
env:
475475
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
476+
VERSION: ${{ needs.prepare.outputs.version }}
476477
run: |
477-
cargo publish -p inferadb-ledger-types --token "$CARGO_REGISTRY_TOKEN" --allow-dirty
478-
echo "Waiting for crates.io to index..."
479-
sleep 45
480-
481-
- name: Publish inferadb-ledger-store
482-
env:
483-
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
484-
run: |
485-
cargo publish -p inferadb-ledger-store --token "$CARGO_REGISTRY_TOKEN" --allow-dirty
486-
echo "Waiting for crates.io to index..."
487-
sleep 45
488-
489-
- name: Publish inferadb-ledger-state
490-
env:
491-
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
492-
run: |
493-
cargo publish -p inferadb-ledger-state --token "$CARGO_REGISTRY_TOKEN" --allow-dirty
494-
echo "Waiting for crates.io to index..."
495-
sleep 45
496-
497-
- name: Publish inferadb-ledger-proto
498-
env:
499-
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
500-
run: |
501-
cargo publish -p inferadb-ledger-proto --token "$CARGO_REGISTRY_TOKEN" --allow-dirty
502-
echo "Waiting for crates.io to index..."
503-
sleep 45
504-
505-
- name: Publish inferadb-ledger-raft
506-
env:
507-
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
508-
run: |
509-
cargo publish -p inferadb-ledger-raft --token "$CARGO_REGISTRY_TOKEN" --allow-dirty
510-
echo "Waiting for crates.io to index..."
511-
sleep 45
512-
513-
- name: Publish inferadb-ledger-sdk
514-
env:
515-
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
516-
run: |
517-
cargo publish -p inferadb-ledger-sdk --token "$CARGO_REGISTRY_TOKEN" --allow-dirty
478+
# Wait for a crate version to appear in the crates.io index.
479+
# Polls every 10s for up to 5 minutes before failing.
480+
wait_for_crate() {
481+
local crate="$1"
482+
local version="$2"
483+
local max_attempts=30
484+
local attempt=0
485+
486+
echo "Waiting for ${crate}@${version} to be indexed on crates.io..."
487+
while [ $attempt -lt $max_attempts ]; do
488+
if cargo search "${crate}" --limit 1 2>/dev/null | grep -q "^${crate} = \"${version}\""; then
489+
echo "${crate}@${version} is now available"
490+
return 0
491+
fi
492+
attempt=$((attempt + 1))
493+
echo " Attempt ${attempt}/${max_attempts} — not yet indexed, retrying in 10s..."
494+
sleep 10
495+
done
496+
497+
echo "ERROR: Timed out waiting for ${crate}@${version} to be indexed after $((max_attempts * 10))s"
498+
return 1
499+
}
500+
501+
CRATES=(inferadb-ledger-types inferadb-ledger-store inferadb-ledger-state inferadb-ledger-proto inferadb-ledger-raft inferadb-ledger-sdk)
502+
LAST_INDEX=$(( ${#CRATES[@]} - 1 ))
503+
504+
for i in "${!CRATES[@]}"; do
505+
crate="${CRATES[$i]}"
506+
echo "Publishing ${crate}..."
507+
cargo publish -p "${crate}" --token "$CARGO_REGISTRY_TOKEN" --allow-dirty
508+
509+
# Wait for indexing before publishing the next crate (skip for last crate)
510+
if [ "$i" -lt "$LAST_INDEX" ]; then
511+
wait_for_crate "${crate}" "${VERSION}"
512+
fi
513+
done

0 commit comments

Comments
 (0)