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