Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 56 additions & 7 deletions .github/workflows/release-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,51 @@ jobs:
skipped_count=0
failed_count=0

version_for() {
if [[ "$1" == "sof-solana-gossip" ]]; then
cargo pkgid --manifest-path "crates/sof-solana-gossip/Cargo.toml" | awk -F'[#@]' '{print $NF}'
else
cargo pkgid -p "$1" | awk -F'[#@]' '{print $NF}'
fi
}

publish_cmd() {
local pkg="$1"
shift
if [[ "${pkg}" == "sof-solana-gossip" ]]; then
cargo publish --manifest-path "crates/sof-solana-gossip/Cargo.toml" --no-verify --allow-dirty "$@"
else
cargo publish -p "${pkg}" --locked "$@"
fi
}

crate_is_published() {
local pkg="$1"
local version="$2"
curl -fsSLo /dev/null "https://crates.io/api/v1/crates/${pkg}/${version}"
}

wait_for_registry() {
local pkg="$1"
local version="$2"
local attempt
for attempt in $(seq 1 20); do
if crate_is_published "${pkg}" "${version}"; then
return 0
fi
echo "Waiting for ${pkg} v${version} to appear in crates.io index (${attempt}/20)..."
sleep 15
done

echo "Error: ${pkg} v${version} did not become visible on crates.io in time"
return 1
}

# Define crates in dependency order
crates=("sof-gossip-tuning" "sof" "sof-tx")
crates=("sof-gossip-tuning" "sof-solana-gossip" "sof" "sof-tx")

for pkg in "${crates[@]}"; do
crate_version="$(cargo pkgid -p "$pkg" | awk -F'[#@]' '{print $NF}')"
crate_version="$(version_for "$pkg")"

if [[ "${crate_version}" != "${tag_version}" ]]; then
echo ">>> Skipping $pkg: version (${crate_version}) does not match tag (${tag_version})"
Expand All @@ -70,9 +110,19 @@ jobs:
fi

matched_count=$((matched_count + 1))

if crate_is_published "$pkg" "${crate_version}"; then
echo ">>> Already published $pkg v${crate_version}"
already_published_count=$((already_published_count + 1))
if [[ "$pkg" == "sof-gossip-tuning" || "$pkg" == "sof-solana-gossip" || "$pkg" == "sof" ]]; then
wait_for_registry "$pkg" "${crate_version}"
fi
continue
fi

echo ">>> Target matches: $pkg v${crate_version}. Dry-running..."
set +e
dry_run_output="$(cargo publish -p "$pkg" --locked --dry-run 2>&1)"
dry_run_output="$(publish_cmd "$pkg" --dry-run 2>&1)"
dry_run_rc=$?
set -e
echo "${dry_run_output}"
Expand All @@ -84,7 +134,7 @@ jobs:

echo ">>> Publishing $pkg v${crate_version} to crates.io..."
set +e
publish_output="$(cargo publish -p "$pkg" --locked 2>&1)"
publish_output="$(publish_cmd "$pkg" 2>&1)"
publish_rc=$?
set -e
echo "${publish_output}"
Expand All @@ -101,9 +151,8 @@ jobs:

# If we just processed the core crate and there are more to go,
# sleep to allow crates.io indexing before downstream publish.
if [[ "$pkg" == "sof-gossip-tuning" || "$pkg" == "sof" ]]; then
echo "Waiting for crates.io indexing..."
sleep 30
if [[ "$pkg" == "sof-gossip-tuning" || "$pkg" == "sof-solana-gossip" || "$pkg" == "sof" ]]; then
wait_for_registry "$pkg" "${crate_version}"
fi
done

Expand Down