diff --git a/.github/workflows/auto-update-core.yml b/.github/workflows/auto-update-core.yml index 6dd6e80a..74370d42 100644 --- a/.github/workflows/auto-update-core.yml +++ b/.github/workflows/auto-update-core.yml @@ -20,6 +20,29 @@ jobs: - name: Setup Repo uses: ./tools/github/setup-repo + # The SDK dispatches right after publishing, before npm serves the new versions. + - name: Wait for published versions on npm + shell: bash + env: + PACKAGES: ${{ toJson(github.event.client_payload.packages) }} + run: | + for row in $(echo "$PACKAGES" | jq -c '.[]'); do + PKG=$(echo "$row" | jq -r '.name') + VER=$(echo "$row" | jq -r '.version') + + for attempt in $(seq 1 10); do + if [ "$(npm view "$PKG@$VER" version 2>/dev/null)" = "$VER" ]; then + echo "✅ $PKG@$VER is available" + continue 2 + fi + echo "⏳ $PKG@$VER not on npm yet (attempt $attempt/10)" + sleep 30 + done + + echo "::error::$PKG@$VER was not available on npm after 5 minutes" + exit 1 + done + - name: Update @swapkit/* dependencies shell: bash run: |