8000 Update generate index workflow · asusevski/llama-cpp-python@3fcfa8b · GitHub
[go: up one dir, main page]

Skip to content

Commit 3fcfa8b

Browse files
committed
Update generate index workflow
1 parent cdf7be7 commit 3fcfa8b

File tree

3 files changed

+62
-42
lines changed

3 files changed

+62
-42
lines changed

.github/workflows/generate-index-from-release.yaml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,23 +34,10 @@ jobs:
3434
uses: actions/configure-pages@v4
3535
- name: Build
3636
run: |
37-
mkdir index
38-
mkdir index/whl
39-
mkdir index/whl/cpu
40-
mkdir index/whl/cpu/llama-cpp-python
41-
42-
echo "<!DOCTYPE html>" > index.html
43-
echo "<html>" >> index.html
44-
echo " <head></head>" >> index.html
45-
echo " <body>" >> index.html
46-
echo " <a href=\"llama-cpp-python/\">llama-cpp-python</a>" >> index.html
47-
echo " <br>"
48-
echo " </body>" >> index.html
49-
echo "</html>" >> index.html
50-
51-
cp index.html index/whl/cpu/index.html
52-
53-
./scripts/release-to-pypi-index.sh > index/whl/cpu/llama-cpp-python/index.html
37+
./scripts/releases-to-pep-503.sh index/whl/cpu '^[v]?[0-9]+\.[0-9]+\.[0-9]+$'
38+
./scripts/releases-to-pep-503.sh index/whl/cu121 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu121$'
39+
./scripts/releases-to-pep-503.sh index/whl/cu122 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu122$'
40+
./scripts/releases-to-pep-503.sh index/whl/metal '^[v]?[0-9]+\.[0-9]+\.[0-9]+-metal$'
5441
- name: Upload artifact
5542
uses: actions/upload-pages-artifact@v3
5643
with:

8000 scripts/release-to-pep-503.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/bin/bash
2+
3+
# Get output directory or default to index/whl/cpu
4+
output_dir=${1:-"index/whl/cpu"}
5+
6+
# Create output directory
7+
mkdir -p $output_dir
8+
9+
# Change to output directory
10+
pushd $output_dir
11+
12+
# Create an index html file
13+
echo "<!DOCTYPE html>" > index.html
14+
echo "<html>" >> index.html
15+
echo " <head></head>" >> index.html
16+
echo " <body>" >> index.html
17+
echo " <a href=\"llama-cpp-python/\">llama-cpp-python</a>" >> index.html
18+
echo " <br>" >> index.html
19+
echo " </body>" >> index.html
20+
echo "</html>" >> index.html
21+
echo "" >> index.html
22+
23+
# Create llama-cpp-python directory
24+
mkdir -p llama-cpp-python
25+
26+
# Change to llama-cpp-python directory
27+
pushd llama-cpp-python
28+
29+
# Create an index html file
30+
echo "<!DOCTYPE html>" > index.html
31+
echo "<html>" >> index.html
32+
echo " <body>" >> index.html
33+
echo " <h1>Links for llama-cpp-python</h1>" >> index.html
34+
35+
# Get all releases
36+
releases=$(curl -s https://api.github.com/repos/abetlen/llama-cpp-python/releases | jq -r .[].tag_name)
37+
38+
# Get pattern from second arg or default to valid python package version pattern
39+
pattern=${2:-"^[v]?[0-9]+\.[0-9]+\.[0-9]+$"}
40+
41+< 8000 /span>
# Filter releases by pattern
42+
releases=$(echo $releases | tr ' ' '\n' | grep -E $pattern)
43+
44+
# For each release, get all assets
45+
for release in $releases; do
46+
assets=$(curl -s https://api.github.com/repos/abetlen/llama-cpp-python/releases/tags/$release | jq -r .assets)
47+
echo " <h2>$release</h2>" >> index.html
48+
for asset in $(echo $assets | jq -r .[].browser_download_url); do
49+
if [[ $asset == *".whl" ]]; then
50+
echo " <a href=\"$asset\">$asset</a>" >> index.html
51+
echo " <br>" >> index.html
52+
fi
53+
done
54+
done
55+
56+
echo " </body>" >> index.html
57+
echo "</html>" >> index.html
58+
echo "" >> index.html

scripts/release-to-pypi-index.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0