Skip to content

Commit ca664e1

Browse files
committed
fix: retry publish while crates.io index propagates the just-published sibling
cargo's index lookup lags the registry API after an upload, so a dependent fails to resolve its freshly published sibling. Retry each crate up to 50 times (15s apart) and settle 60s between crates so the index catches up instead of aborting the whole release.
1 parent c43f955 commit ca664e1

1 file changed

Lines changed: 20 additions & 13 deletions

File tree

‎Justfile‎

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,33 @@ publish-check:
7171
# registry token). Published per-crate in dependency order rather than via
7272
# `cargo publish --workspace` so the step is idempotent: a crate that is
7373
# already on crates.io is skipped instead of aborting the whole run, which is
74-
# what lets a retagged force-push re-run resume after a partial upload. A short
75-
# pause after each upload lets crates.io index the new version before its
76-
# dependents resolve it (cargo's built-in wait is too short under load and
77-
# otherwise times out). `shellflow-muxy` and the `shellflow` binary are
78-
# `publish = false` (their deps are git-only) and are not published here.
74+
# what lets a retagged force-push re-run resume after a partial upload. A crate
75+
# is retried while its just-published sibling is still propagating through
76+
# crates.io's index — cargo otherwise fails the entire run the moment a
77+
# dependent cannot yet resolve that dependency. `shellflow-muxy` and the
78+
# `shellflow` binary are `publish = false` (their deps are git-only) and are
79+
# not published here.
7980
publish:
8081
#!/usr/bin/env bash
8182
set -uo pipefail
8283
CRATES=(shellflow-text shellflow-dsl shellflow-core shellflow-secrets)
8384
n=${#CRATES[@]}
8485
for ((i = 0; i < n; i++)); do
8586
pkg=${CRATES[i]}
86-
if out=$(cargo publish -p "$pkg" 2>&1); then
87-
echo "published $pkg"
88-
if ((i < n - 1)); then sleep 90; fi
89-
elif echo "$out" | grep -qiE "already (uploaded|published)|already exists|is already"; then
90-
echo "skip $pkg (already on crates.io)"
91-
else
92-
echo "failed to publish $pkg:"; printf '%s\n' "$out"; exit 1
93-
fi
87+
published=0
88+
for attempt in $(seq 1 50); do
89+
if out=$(cargo publish -p "$pkg" 2>&1); then
90+
echo "published $pkg (attempt $attempt)"; published=1; break
91+
elif echo "$out" | grep -qiE "already (uploaded|published)|already exists|is already"; then
92+
echo "skip $pkg (already on crates.io)"; published=1; break
93+
elif echo "$out" | grep -qiE "no matching package|timed out|waiting for published"; then
94+
echo "$pkg blocked on dependency index propagation (attempt $attempt/40); retrying in 15s"; sleep 15
95+
else
96+
echo "failed to publish $pkg:"; printf '%s\n' "$out"; exit 1
97+
fi
98+
done
99+
if ((published == 0)); then echo "gave up on $pkg after 50 attempts"; exit 1; fi
100+
if ((i < n - 1)); then sleep 60; fi
94101
done
95102
96103
# Fail if Chinese characters are present in tracked files

0 commit comments

Comments
 (0)