From de1aa37b505b936a32cf668454c9b2f7f1959d4b Mon Sep 17 00:00:00 2001
From: David Tolnay <dtolnay@gmail.com>
Date: Sun, 12 Feb 2023 12:07:24 -0800
Subject: [PATCH] Set CARGO_REGISTRIES_CRATES_IO_PROTOCOL

---
 action.yml | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/action.yml b/action.yml
index 656c2b1..21e1bc8 100644
--- a/action.yml
+++ b/action.yml
@@ -98,9 +98,11 @@ runs:
       shell: bash
 
     - run: |
-        : enable Cargo sparse registry  # ignored by stable cargo
-        if [ -z ${CARGO_UNSTABLE_SPARSE_REGISTRY+set} ]; then
-          echo CARGO_UNSTABLE_SPARSE_REGISTRY=true >> $GITHUB_ENV
+        : enable Cargo sparse registry  # except on 1.66 and 1.67, on which it is unstable
+        if [ -z ${CARGO_REGISTRIES_CRATES_IO_PROTOCOL+set} ] \
+          && ! rustc +${{steps.parse.outputs.toolchain}} --version --verbose | grep -q '^release: 1\.6[67]\.'
+        then
+          echo CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse >> $GITHUB_ENV
         fi
       shell: bash