fix: 更改cargo 配置文件的写入方式
This commit is contained in:
parent
56311d6351
commit
bd0dd7428a
63
action.yml
63
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 <<EOF
|
||||
[source.crates-io]
|
||||
replace-with = 'rsproxy-sparse'
|
||||
echo "[source.crates-io]" > ~/.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')
|
||||
|
||||
[registries.rsproxy]
|
||||
index = "https://rsproxy.cn/crates.io-index"
|
||||
}}
|
||||
fi
|
||||
|
||||
[net]
|
||||
git-fetch-with-cli = true
|
||||
EOF
|
||||
- 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
|
||||
|
||||
- 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
|
||||
|
|
|
|||
Loading…
Reference in New Issue