#!/bin/bash
# Get output directory or default to index/whl/cpu
output_dir=${1:-"index/whl/cpu"}
# Create output directory
mkdir -p $output_dir
# Change to output directory
pushd $output_dir
# Create an index html file
echo "" > index.html
echo "" >> index.html
echo "
" >> index.html
echo " " >> index.html
echo " llama-cpp-python" >> index.html
echo "
" >> index.html
echo " " >> index.html
echo "" >> index.html
echo "" >> index.html
# Create llama-cpp-python directory
mkdir -p llama-cpp-python
# Change to llama-cpp-python directory
pushd llama-cpp-python
# Create an index html file
echo "" > index.html
echo "" >> index.html
echo " " >> index.html
echo " Links for llama-cpp-python
" >> index.html
# Get all releases
releases=$(curl -s https://api.github.com/repos/abetlen/llama-cpp-python/releases | jq -r .[].tag_name)
# Get pattern from second arg or default to valid python package version pattern
pattern=${2:-"^[v]?[0-9]+\.[0-9]+\.[0-9]+$"}
# Filter releases by pattern
releases=$(echo $releases | tr ' ' '\n' | grep -E $pattern)
# For each release, get all assets
for release in $releases; do
assets=$(curl -s https://api.github.com/repos/abetlen/llama-cpp-python/releases/tags/$release | jq -r .assets)
echo " $release
" >> index.html
for asset in $(echo $assets | jq -r .[].browser_download_url); do
if [[ $asset == *".whl" ]]; then
echo " $asset" >> index.html
echo "
" >> index.html
fi
done
done
echo " " >> index.html
echo "" >> index.html
echo "" >> index.html