Skip to content

Commit

Permalink
fix for artifact download file name changes since 0.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
virtualstaticvoid committed Aug 31, 2024
1 parent a96f05b commit 571dc7f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 9 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
paths-ignore:
- '**.md'

env:
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
test:
strategy:
Expand All @@ -18,8 +21,20 @@ jobs:

steps:
- name: asdf_plugin_test
uses: asdf-vm/actions/[email protected]
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"
26 changes: 20 additions & 6 deletions bin/install
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 571dc7f

Please sign in to comment.