From 89a6f4a505b70707e4d73e256cd554bd71bbb573 Mon Sep 17 00:00:00 2001
From: Yi Lin <qinsoon@gmail.com>
Date: Mon, 8 Aug 2022 13:32:53 +1200
Subject: [PATCH] Add a retry mechanism for publishing mmtk-core to crates.io
 (#618)

---
 .github/workflows/cargo-publish.yml | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/cargo-publish.yml b/.github/workflows/cargo-publish.yml
index 5a10621747..10efaed1d0 100644
--- a/.github/workflows/cargo-publish.yml
+++ b/.github/workflows/cargo-publish.yml
@@ -22,6 +22,15 @@ jobs:
       - name: Publish sub crates
         run: |
           cargo publish --manifest-path=macros/Cargo.toml
+      # Publish MMTk core.
+      # As mmtk-core depends on the crate we just publish above, in practice there could be
+      # a delay before we can find the exact version for the dependent crate on crates.io.
+      # The script will retry publish for 5 times with 60 seconds between the retries.
       - name: Public mmtk-core
         run: |
-          cargo publish
+          for n in {1..5}; do
+            echo "Attempt #"$n
+            cargo publish && break
+            echo "Wait for Retry #"$n
+            sleep 60
+          done