#!/usr/bin/env fish
# Stage: publish tracing-subscriber-init to crates.io.
#
# A straight port of ruarango/sss's publish-crates.fish, trimmed to a
# single crate (no dependency-ordered multi-crate publish needed) --
# expects `cargo login` to already be configured with a crates.io API
# token on this machine (repomon has no secrets-injection mechanism to
# read one from).
source (path dirname (status --current-filename))/lib.fish
cd (rel_repo_root)
or rel_die "not inside the tracing-subscriber-init git repo"
rel_resolve_tag
rel_require_cmd cargo
if rel_is_rc
rel_log "$RELEASE_TAG is a pre-release tag -- nothing to do here"
exit 0
end
# `cargo publish` blocks until the crate is queryable, but the index can
# still lag briefly -- retry a few times rather than failing the whole
# release over a transient index delay.
for attempt in 1 2 3 4 5
if cargo publish --locked
rel_log "published $RELEASE_TAG to crates.io"
exit 0
end
rel_warn "publish attempt $attempt failed; waiting 30s for the index..."
sleep 30
end
rel_die "all publish attempts for $RELEASE_TAG failed."