#!/usr/bin/env bash # Safeguard: a crate published on a private registry declares `publish = [""]` in its # Cargo.toml, so that cargo itself refuses any publication elsewhere (crates.io for example). # Not applicable: kind without publication (PUBLISH=no), registry absent or crates-io. set -euo pipefail . "$(dirname "$0")/common.sh" [ "${PUBLISH:-yes}" = no ] && exit 0 { [ -n "$REGISTRY" ] && [ "$REGISTRY" != crates-io ]; } || exit 0 [ -f "$CARGO_TOML" ] || exit 0 grep -qE "^publish[[:space:]]*=[[:space:]]*\[[[:space:]]*\"$REGISTRY\"[[:space:]]*\]" "$CARGO_TOML" && exit 0 err "✗ $CARGO_TOML : publish = [\"$REGISTRY\"] missing in [package] (without it, cargo publish would accept crates.io)" exit 1