Fix installation script on MacOS (#1263)

Fixed #1254

and also add CI for installation script and shellcheck.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-08-09 19:37:26 +10:00 committed by GitHub
parent 7f1ddd1dd7
commit 1c886d8897
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 118 additions and 3 deletions

84
.github/workflows/install-script.yml vendored Normal file
View file

@ -0,0 +1,84 @@
name: Test install-script
on:
merge_group:
pull_request:
types:
- opened
- reopened
- synchronize
paths:
- install-from-binstall-release.ps1
- install-from-binstall-release.sh
push:
branches:
- main
paths:
- install-from-binstall-release.ps1
- install-from-binstall-release.sh
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
unix:
strategy:
fail-fast: false
matrix:
os: [macos-latest, ubuntu-latest]
set_cargo_home: [t, f]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set `CARGO_HOME`
if: matrix.set_cargo_home == 't'
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
run: ./install-from-binstall-release.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Verify `cargo-binstall` installation
run: |
which cargo-binstall
cargo binstall -vV
windows:
strategy:
fail-fast: false
matrix:
set_cargo_home: [t, f]
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- 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
run: ./install-from-binstall-release.ps1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Verify `cargo-binstall` installation
run: cargo binstall -vV

32
.github/workflows/shellcheck.yml vendored Normal file
View file

@ -0,0 +1,32 @@
name: Shellcheck
on:
merge_group:
pull_request:
types:
- opened
- reopened
- synchronize
paths:
- '**.sh'
push:
branches:
- main
paths:
- '**.sh'
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.event.pull_request.number || github.sha }}
cancel-in-progress: true
jobs:
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: taiki-e/install-action@v2
with:
tool: fd-find
- name: shellcheck
run: fd -e sh -t f -X shellcheck

View file

@ -27,9 +27,8 @@ fi
./cargo-binstall -y --force cargo-binstall
if ! [[ -v CARGO_HOME ]]; then
CARGO_HOME=$HOME/.cargo
fi
CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
if ! [[ ":$PATH:" == *":$CARGO_HOME/bin:"* ]]; then
echo
printf "\033[0;31mYour path is missing %s, you might want to add it.\033[0m\n" "$CARGO_HOME/bin"