#!/usr/bin/env fish
# Stage: publish to crates.io. Retries a few times 30s apart -- crates.io's
# index can lag right after a dependency's own publish, and this pipeline
# has no reason to assume it's the first to hit that race.
source (path dirname (status --current-filename))/lib.fish
cd (rel_repo_root)
or rel_die "not inside the cargo-matrix git repo"
rel_resolve_tag
if rel_is_rc
rel_log "$RELEASE_TAG is a pre-release tag -- skipping crates.io publish"
exit 0
end
set -l attempts 5
set -l delay 30
for i in (seq $attempts)
rel_log "cargo publish --locked (attempt $i/$attempts)"
if cargo publish --locked
rel_log "published cargo-matrix $RELEASE_PKGVER to crates.io"
exit 0
end
if test $i -lt $attempts
rel_warn "cargo publish failed, retrying in {$delay}s"
sleep $delay
end
end
rel_die "cargo publish failed after $attempts attempts"