From 322fff7e3d8af8135c8ffb4d4d37521a7d53006d Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Thu, 14 Jul 2022 22:16:02 +0100 Subject: [PATCH 1/3] fixnum depends on macros, so macros must go first --- .github/scripts/publish-crate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/publish-crate.sh b/.github/scripts/publish-crate.sh index b599c127..fb1224b2 100644 --- a/.github/scripts/publish-crate.sh +++ b/.github/scripts/publish-crate.sh @@ -2,7 +2,7 @@ set -e # Fail if any command fails -PROJECTS_TO_RELEASE_IN_ORDER="agb-fixnum agb-macros agb-image-converter agb-sound-converter agb" +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" From 94688d517bbc8cae118d31a579b240dbac397319 Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Thu, 14 Jul 2022 22:32:58 +0100 Subject: [PATCH 2/3] Check that the crate has finished publishing --- .github/scripts/publish-crate.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/scripts/publish-crate.sh b/.github/scripts/publish-crate.sh index fb1224b2..00f1f3db 100644 --- a/.github/scripts/publish-crate.sh +++ b/.github/scripts/publish-crate.sh @@ -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 From 5ee771bd0f3e054d5826d9fa9608b13dc91926ea Mon Sep 17 00:00:00 2001 From: Gwilym Kuiper Date: Thu, 14 Jul 2022 22:33:39 +0100 Subject: [PATCH 3/3] Print attempt number --- .github/scripts/publish-crate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/publish-crate.sh b/.github/scripts/publish-crate.sh index 00f1f3db..075cb661 100644 --- a/.github/scripts/publish-crate.sh +++ b/.github/scripts/publish-crate.sh @@ -20,10 +20,10 @@ function wait_for_release() { local expected_version expected_version=$(grep -E '^version' Cargo.toml | grep -oE '[0-9.]+') - local attempts=0 + local attempts=1 while [ $attempts -le 15 ]; do - echo "Polling crates.io to see if the version has updated" + echo "Polling crates.io to see if the version has updated (attempt $attempts)" if curl "$url_to_poll" | grep "$expected_version"; then return fi