Add cargo-binstall installation path to GITHUB_PATH (#1748)

* Add cargo-binstall installation path to GITHUB_PATH in install-from-binstall-release.sh

Fixed #1714

* Add cargo-binstall installation path to GITHUB_PATH in install-from-binstall-release.ps1

* Update install-script.yml to test

* Fix use of env var in install-from-binstall-release.ps1
This commit is contained in:
Jiahao XU 2024-06-13 23:43:39 +10:00 committed by GitHub
parent 9a270f03b6
commit 05f488322e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 9 deletions

View file

@ -43,7 +43,6 @@ jobs:
CARGO_HOME="$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-home')" CARGO_HOME="$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-home')"
mkdir -p "${CARGO_HOME}/bin" mkdir -p "${CARGO_HOME}/bin"
echo "CARGO_HOME=$CARGO_HOME" >> "$GITHUB_ENV" echo "CARGO_HOME=$CARGO_HOME" >> "$GITHUB_ENV"
echo "${CARGO_HOME}/bin" >> $GITHUB_PATH
- name: Install `cargo-binstall` using scripts - name: Install `cargo-binstall` using scripts
run: ./install-from-binstall-release.sh run: ./install-from-binstall-release.sh
@ -73,7 +72,6 @@ jobs:
CARGO_HOME="$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-home')" CARGO_HOME="$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-home')"
mkdir -p "${CARGO_HOME}/bin" mkdir -p "${CARGO_HOME}/bin"
echo "CARGO_HOME=$CARGO_HOME" >> "$GITHUB_ENV" echo "CARGO_HOME=$CARGO_HOME" >> "$GITHUB_ENV"
echo "${CARGO_HOME}/bin" >> $GITHUB_PATH
- name: Install `cargo-binstall` using scripts - name: Install `cargo-binstall` using scripts
run: ./install-from-binstall-release.ps1 run: ./install-from-binstall-release.ps1
@ -101,7 +99,6 @@ jobs:
CARGO_HOME="$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-home')" CARGO_HOME="$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-home')"
mkdir -p "${CARGO_HOME}/bin" mkdir -p "${CARGO_HOME}/bin"
echo "CARGO_HOME=$CARGO_HOME" >> "$GITHUB_ENV" echo "CARGO_HOME=$CARGO_HOME" >> "$GITHUB_ENV"
echo "${CARGO_HOME}/bin" >> $GITHUB_PATH
- name: Install `cargo-binstall` using scripts - name: Install `cargo-binstall` using scripts
shell: bash shell: bash

View file

@ -20,7 +20,11 @@ Remove-Item -Force $tmpdir\cargo-binstall.zip
Remove-Item -Recurse -Force $tmpdir\cargo-binstall Remove-Item -Recurse -Force $tmpdir\cargo-binstall
$cargo_home = if ($Env:CARGO_HOME -ne $null) { $Env:CARGO_HOME } else { "$HOME\.cargo" } $cargo_home = if ($Env:CARGO_HOME -ne $null) { $Env:CARGO_HOME } else { "$HOME\.cargo" }
if ($Env:Path -split ";" -notcontains "$cargo_home\bin") { if ($Env:Path -split ";" -notcontains "$cargo_home\bin") {
if (($Env:CI -ne $null) -and ($Env:GITHUB_PATH -ne $null)) {
Add-Content -Path "$Env:GITHUB_PATH" -Value "$cargo_home\bin"
} else {
Write-Host "" Write-Host ""
Write-Host "Your path is missing $cargo_home\bin, you might want to add it." -ForegroundColor Red Write-Host "Your path is missing $cargo_home\bin, you might want to add it." -ForegroundColor Red
Write-Host "" Write-Host ""
} }
}

View file

@ -36,7 +36,11 @@ fi
CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}" CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
if ! [[ ":$PATH:" == *":$CARGO_HOME/bin:"* ]]; then if ! [[ ":$PATH:" == *":$CARGO_HOME/bin:"* ]]; then
if [ -n "$CI" ] && [ -n "$GITHUB_PATH" ]; then
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
else
echo echo
printf "\033[0;31mYour path is missing %s, you might want to add it.\033[0m\n" "$CARGO_HOME/bin" printf "\033[0;31mYour path is missing %s, you might want to add it.\033[0m\n" "$CARGO_HOME/bin"
echo echo
fi fi
fi