From b415b0d7e6b3d4f49d09bf29c767324ecf8adadb Mon Sep 17 00:00:00 2001 From: Jacob Hummer Date: Fri, 12 Jan 2024 20:22:51 -0600 Subject: [PATCH] Fix install-from-binstall-release.sh for Git Bash users on Windows (#1562) * Update install-from-binstall-release.sh * Update install-from-binstall-release.sh * Update install-from-binstall-release.sh Co-authored-by: Jiahao XU * Update install-from-binstall-release.sh Co-authored-by: Jiahao XU * Update install-script.yml * Update install-from-binstall-release.sh * Update install-script.yml --------- Co-authored-by: Jiahao XU --- .github/workflows/install-script.yml | 30 ++++++++++++++++++++++++++++ install-from-binstall-release.sh | 6 ++++++ 2 files changed, 36 insertions(+) diff --git a/.github/workflows/install-script.yml b/.github/workflows/install-script.yml index 26f68e22..fec2960e 100644 --- a/.github/workflows/install-script.yml +++ b/.github/workflows/install-script.yml @@ -82,3 +82,33 @@ jobs: - name: Verify `cargo-binstall` installation run: cargo binstall -vV + + windows-bash: + strategy: + fail-fast: false + matrix: + set_cargo_home: [t, f] + + runs-on: windows-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set `CARGO_HOME` + if: matrix.set_cargo_home == 't' + shell: bash + run: | + CARGO_HOME="$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-home')" + mkdir -p "${CARGO_HOME}/bin" + echo "CARGO_HOME=$CARGO_HOME" >> "$GITHUB_ENV" + echo "${CARGO_HOME}/bin" >> $GITHUB_PATH + + - name: Install `cargo-binstall` using scripts + shell: bash + run: ./install-from-binstall-release.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Verify `cargo-binstall` installation + shell: bash + run: cargo binstall -vV diff --git a/install-from-binstall-release.sh b/install-from-binstall-release.sh index 7630eeb4..90686cba 100755 --- a/install-from-binstall-release.sh +++ b/install-from-binstall-release.sh @@ -20,6 +20,12 @@ elif [ "$os" == "Linux" ]; then url="${base_url}${target}.tgz" curl -L --proto '=https' --tlsv1.2 -sSf "$url" | tar -xvzf - +elif [ "${OS-}" = "Windows_NT" ]; then + machine="$(uname -m)" + target="${machine}-pc-windows-msvc" + url="${base_url}${target}.zip" + curl -LO --proto '=https' --tlsv1.2 -sSf "$url" + unzip "cargo-binstall-${target}.zip" else echo "Unsupported OS ${os}" exit 1