From 571dc7f67d7a92c711d08c3200f1c15dd6e4ea80 Mon Sep 17 00:00:00 2001 From: Chris Stefano Date: Sat, 31 Aug 2024 20:51:02 +0100 Subject: [PATCH] fix for artifact download file name changes since 0.3.7 --- .github/workflows/workflow.yml | 21 ++++++++++++++++++--- bin/install | 26 ++++++++++++++++++++------ 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 8b0f02f..ede8331 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -8,6 +8,9 @@ on: paths-ignore: - '**.md' +env: + GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + jobs: test: strategy: @@ -18,8 +21,20 @@ jobs: steps: - name: asdf_plugin_test - uses: asdf-vm/actions/plugin-test@v1.0.1 + uses: asdf-vm/actions/plugin-test@v2 + with: + command: ollama --version + + # these tests to cover when the naming convention of the download files changed + + - name: asdf_plugin_test_0_3_6 + uses: asdf-vm/actions/plugin-test@v2 + with: + command: ollama --version + version: "0.3.6" + + - name: asdf_plugin_test_0_3_7 + uses: asdf-vm/actions/plugin-test@v2 with: command: ollama --version - env: - GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + version: "0.3.7" diff --git a/bin/install b/bin/install index 429660b..37462bc 100755 --- a/bin/install +++ b/bin/install @@ -13,15 +13,24 @@ install_plugin() { local version=$2 local install_path=$3 + local platform=$(get_platform) local bin_install_path="$install_path/bin" local download_url="$(get_download_url $install_type $version)" - mkdir -p "${bin_install_path}" - - local bin_path="${bin_install_path}/ollama" echo "Downloading ollama from ${download_url}" - curl -s -L "$download_url" -o "$bin_path" - chmod +x $bin_path + + # releases for Mac and for versions prior to 0.3.7 provide the binary + if [ "${platform}" == "darwin" ] || [ "$(printf '%s\n' "0.3.6" "$version" | sort -rV | head -n1)" = "0.3.6" ]; then + mkdir -p "${bin_install_path}" + local bin_path="${bin_install_path}/ollama" + curl -sSfL "$download_url" -o "$bin_path" + chmod +x $bin_path + else + pushd $install_path > /dev/null + local tmp_download_file=$(mktemp) + curl -sSfL "$download_url" -o "$tmp_download_file" + tar zxf "$tmp_download_file" || exit 1 + fi } get_platform() { @@ -52,7 +61,12 @@ get_download_url() { if [ "${platform}" == "darwin" ]; then echo "https://github.com/ollama/ollama/releases/download/v${version}/ollama-${platform}" else - echo "https://github.com/ollama/ollama/releases/download/v${version}/ollama-${platform}-${arch}" + # releases since 0.3.7 use tgz for artifact + if [ "$(printf '%s\n' "0.3.7" "$version" | sort -rV | head -n1)" = "$version" ]; then + echo "https://github.com/ollama/ollama/releases/download/v${version}/ollama-${platform}-${arch}.tgz" + else + echo "https://github.com/ollama/ollama/releases/download/v${version}/ollama-${platform}-${arch}" + fi fi }