diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34c38f6..af1d9e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,25 @@ permissions: statuses: write jobs: + test-install-using-action: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Cloud Runtime CLI + uses: ./ + - name: Verify installation + run: vcr --version + test-install-using-script: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Cloud Runtime CLI + shell: sh + run: ./script/install.sh + - name: Verify installation + run: vcr --version build-and-test: runs-on: macos-latest env: diff --git a/script/install.sh b/script/install.sh index 7be85aa..3ac563a 100755 --- a/script/install.sh +++ b/script/install.sh @@ -125,26 +125,33 @@ main() { # If system-wide fails, try user-local directories user_local_paths="$HOME/.local/bin:$HOME/bin:$HOME/.vcr/bin" - IFS=':' read -ra paths <<< "$user_local_paths" - for user_path in "${paths[@]}"; do + oldIFS=$IFS + IFS=: + set -- $user_local_paths + IFS=$oldIFS + + for user_path do if mkdir -p "$user_path" 2>/dev/null && mv "$tmp_dir/${vcr_binary}" "$user_path/vcr" 2>/dev/null; then echo "vcr was installed successfully to $user_path" # Check if the path is already in PATH - if ! echo ":$PATH:" | grep -q ":$user_path:"; then - case $SHELL in - /bin/zsh) shell_profile=".zshrc" ;; - *) shell_profile=".bash_profile" ;; - esac - echo "" - echo "⚠️ Warning: $user_path is not in your \$PATH" - echo "Add the following to your \$HOME/$shell_profile:" - echo " export PATH=\"$user_path:\$PATH\"" - echo "" - echo "Then you can run: vcr --help" - else - echo "Run 'vcr --help' to get started" - fi + case ":$PATH:" in + *":$user_path:"*) + echo "Run 'vcr --help' to get started" + ;; + *) + case $SHELL in + /bin/zsh) shell_profile=".zshrc" ;; + *) shell_profile=".bash_profile" ;; + esac + echo "" + echo "⚠️ Warning: $user_path is not in your \$PATH" + echo "Add the following to your \$HOME/$shell_profile:" + echo " export PATH=\"$user_path:\$PATH\"" + echo "" + echo "Then you can run: vcr --help" + ;; + esac exit 0 fi done