Check that the crate has finished publishing

This commit is contained in:
Gwilym Kuiper 2022-07-14 22:32:58 +01:00
parent 322fff7e3d
commit 94688d517b

View file

@ -2,11 +2,43 @@
set -e # Fail if any command fails
function wait_for_release() {
local package="$0"
local package_with_underscores="${package/-/_}"
local first_two_characters="${package_with_underscores:0:2}"
local second_two_characters="${package_with_underscores:2:2}"
local path="$first_two_characters/$second_two_characters"
if [ "$package" == "agb" ]; then
path="3/a"
fi
local url_to_poll="https://raw.githubusercontent.com/rust-lang/crates.io-index/master/$path/$package_with_underscores"
local expected_version
expected_version=$(grep -E '^version' Cargo.toml | grep -oE '[0-9.]+')
local attempts=0
while [ $attempts -le 15 ]; do
echo "Polling crates.io to see if the version has updated"
if curl "$url_to_poll" | grep "$expected_version"; then
return
fi
sleep 30s
attempts=$((attempts + 1))
done
}
PROJECTS_TO_RELEASE_IN_ORDER="agb-macros agb-fixnum agb-image-converter agb-sound-converter agb"
for PROJECT in $PROJECTS_TO_RELEASE_IN_ORDER; do
pushd "$PROJECT"
echo "Publishing $PROJECT"
cargo publish
wait_for_release "$PROJECT"
popd
done