From bd0dd7428a1f21b4d77b1f8b064098bd9236a949 Mon Sep 17 00:00:00 2001 From: chenwj113 Date: Wed, 21 Aug 2024 16:46:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9B=B4=E6=94=B9cargo=20=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E7=9A=84=E5=86=99=E5=85=A5=E6=96=B9?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 63 +++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/action.yml b/action.yml index 9c93f71..725d826 100644 --- a/action.yml +++ b/action.yml @@ -113,23 +113,60 @@ runs: echo "RUSTUP_UPDATE_ROOT=https://rsproxy.cn/rustup" >> $GITHUB_ENV fi if [[ ! -f ~/.cargo/config ]]; then - mkdir -p ~/.cargo - cat > ~/.cargo/config < ~/.cargo/config + echo "replace-with = 'rsproxy-sparse'" >> ~/.cargo/config + echo "[source.rsproxy]" >> ~/.cargo/config + echo "registry = 'https://rsproxy.cn/crates.io-index'" >> ~/.cargo/config + echo "[source.rsproxy-sparse]" >> ~/.cargo/config + echo "registry = 'sparse+https://rsproxy.cn/index/'" >> ~/.cargo/config + echo "[registries.rsproxy]" >> ~/.cargo/config + echo "index = 'https://rsproxy.cn/crates.io-index'" >> ~/.cargo/config + echo "[net]" >> ~/.cargo/config + echo "git-fetch-with-cli = true" >> ~/.cargo/config + fi - [source.rsproxy] - registry = "https://rsproxy.cn/crates.io-index" + - name: Cache Rust toolchain + uses: actions/cache@v3 + with: + path: | + $HOME/.cargo/registry + $HOME/.cargo/git + $HOME/.cargo/registry/cache + $HOME/.cargo/registry/index + key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-rust- + fi - [source.rsproxy-sparse] - registry = "sparse+https://rsproxy.cn/index/" + - name: Cache Rust toolchain + uses: actions/cache@v3 + with: + path: | + $HOME/.cargo/registry + $HOME/.cargo/git + $HOME/.cargo/registry/cache + $HOME/.cargo/registry/index + key: ${{ runner.os }}-rust-${{ hashFiles('**/Cargo.lock') + + }} + fi - [registries.rsproxy] - index = "https://rsproxy.cn/crates.io-index" + - name: Cache Rust toolchain + uses: actions/cache@v3 + with: + path: | + $HOME/.cargo/registry + $HOME/.cargo/git + $HOME/.cargo/registry/cache + $HOME/.cargo/registry/index + fi - [net] - git-fetch-with-cli = true - EOF + - name: Install Rust toolchain + if: runner.os != 'Windows' + shell: bash + run: | + if ! command -v rustup &> /dev/null ; then + curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://rsproxy.cn/rustup-init.sh" | sh -s -- --default-toolchain none -y fi - name: Install Rust toolchain