diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 92f06820..a51ff6a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -170,7 +170,7 @@ jobs: run: ./setup-cli/assert/not-installed.sh shell: bash - - run: curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/${{ github.sha }}/install.sh | sh + - run: curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/install.sh | sh shell: bash - run: databricks version @@ -189,6 +189,33 @@ jobs: if: matrix.os == 'windows-latest' run: ./setup-cli/assert/path.sh /c/Windows/databricks + - run: rm -f "$(which databricks)" + if: matrix.os != 'windows-latest' + shell: bash + + - name: Assert databricks CLI is not already installed + run: ./setup-cli/assert/not-installed.sh + if: matrix.os != 'windows-latest' + shell: bash + + - run: curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/install.sh | sh -s ~/.local/bin + if: matrix.os != 'windows-latest' + shell: bash + + - run: PATH="$HOME/.local/bin:$PATH" databricks version + if: matrix.os != 'windows-latest' + shell: bash + + - name: Assert the version of the CLI installed + run: PATH="$HOME/.local/bin:$PATH" ./setup-cli/assert/version.sh $(cat ./setup-cli/VERSION) + if: matrix.os != 'windows-latest' + shell: bash + + - name: Assert installation path is ~/.local/bin for non-windows platforms + run: ./setup-cli/assert/path.sh ~/.local/bin/databricks + if: matrix.os != 'windows-latest' + shell: bash + curl-dbr: # All DBR images are built on top of Ubuntu runs-on: ubuntu-latest @@ -206,7 +233,7 @@ jobs: run: ./setup-cli/assert/not-installed.sh shell: bash - - run: curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/${{ github.sha }}/install.sh | sh + - run: curl -fsSL https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/install.sh | sh shell: bash env: DATABRICKS_RUNTIME_VERSION: value-does-not-matter diff --git a/README.md b/README.md index c7121027..2007ef2a 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,12 @@ To install a specific version, you can replace `main` with a specific release ta curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/v0.243.0/install.sh | sh ``` +To install a specific version, in a specific location (e.g. `~/.local/bin`): + +```bash +curl -fsSL https://raw.githubusercontent.com/databricks/setup-cli/v0.243.0/install.sh | sh -s ~/.local/bin +``` + ## GitHub Actions This repository can be used from GitHub Actions. diff --git a/install.sh b/install.sh index 00b3ce4a..674bae15 100755 --- a/install.sh +++ b/install.sh @@ -27,6 +27,11 @@ MINGW64_NT) ;; esac +# Check for a command-line argument for the target directory +if [ "$#" -gt 0 ]; then + TARGET="$1" +fi + # Set target to ~/bin if DATABRICKS_RUNTIME_VERSION environment variable is set. if [ -n "$DATABRICKS_RUNTIME_VERSION" ]; then # Set the installation target to ~/bin when run on DBR @@ -57,6 +62,9 @@ arm64|aarch64) ;; esac +# Create the target directory if it does not exist +mkdir -p "$TARGET" + # Make sure the target directory is writable. if [ ! -w "$TARGET" ]; then echo "Target directory $TARGET is not writable."