Skip to content

Commit

Permalink
support v0.0.8.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiyuan8 committed Aug 30, 2024
1 parent 3c4abd9 commit b7c2fdf
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/generate-index-from-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ jobs:

- name: Build
run: |
./scripts/releases-to-pep-503.sh index/whl/cpu '^[v]?[0-9]+\.[0-9]+\.[0-9]+$'
# ./scripts/releases-to-pep-503.sh index/whl/cu121 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu121$'
# ./scripts/releases-to-pep-503.sh index/whl/cu122 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu122$'
# ./scripts/releases-to-pep-503.sh index/whl/cu123 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu123$'
./scripts/releases-to-pep-503.sh index/whl/cu124 '^[v]?[0-9]+\.[0-9]+\.[0-9]+-cu124$'
./scripts/releases-to-pep-503.sh index/whl/metal '^[v]?[0-9]+\.[0-9]+\.[0-9]+-metal$'
./scripts/releases-to-pep-503.sh index/whl/cpu '^[v]?[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?$'
# ./scripts/releases-to-pep-503.sh index/whl/cu121 '^[v]?[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?-cu121$'
# ./scripts/releases-to-pep-503.sh index/whl/cu122 '^[v]?[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?-cu122$'
# ./scripts/releases-to-pep-503.sh index/whl/cu123 '^[v]?[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?-cu123$'
./scripts/releases-to-pep-503.sh index/whl/cu124 '^[v]?[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?-cu124$'
./scripts/releases-to-pep-503.sh index/whl/metal '^[v]?[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?-metal$'
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
40 changes: 37 additions & 3 deletions scripts/releases-to-pep-503.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ repo_name="nexa-sdk"
output_dir=${1:-"index/whl/cpu"}

# Create output directory
echo "Creating output directory: $output_dir"
mkdir -p $output_dir

# Change to output directory
echo "Changing to output directory: $output_dir"
pushd $output_dir

# Create an index html file
echo "Creating index.html in $output_dir"
echo "<!DOCTYPE html>" > index.html
echo "<html>" >> index.html
echo " <head></head>" >> index.html
Expand All @@ -24,20 +27,27 @@ echo "</html>" >> index.html
echo "" >> index.html

# Create ${package_name} directory
echo "Creating package directory: ${package_name}"
mkdir -p ${package_name}

# Change to ${package_name} directory
echo "Changing to package directory: ${package_name}"
pushd ${package_name}

# Create an index html file
echo "Creating index.html in ${package_name} directory"
echo "<!DOCTYPE html>" > index.html
echo "<html>" >> index.html
echo " <body>" >> index.html
echo " <h1>Links for ${package_name}</h1>" >> index.html

# Get all releases
echo "Fetching all releases from GitHub for repository: ${repo_name}"
releases=$(curl -s https://api.github.com/repos/NexaAI/${repo_name}/releases | jq -r .[].tag_name)

# Output all retrieved releases for debugging
echo "All releases retrieved: $releases"

# Get pattern from second arg or default to valid python package version pattern
# pattern example 1 : v0.1.0
# pattern example 2 : 0.1.0
Expand All @@ -47,36 +57,58 @@ releases=$(curl -s https://api.github.com/repos/NexaAI/${repo_name}/releases | j
pattern=${2:-"^[v]?[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?(-[a-zA-Z0-9]+)?$"}

# Filter releases by pattern
echo "Filtering releases with pattern: $pattern"
releases=$(echo $releases | tr ' ' '\n' | grep -E $pattern)

# Output filtered releases for debugging
echo "Filtered releases: $releases"

# For each release, get all assets
for release in $releases; do
echo "Processing release: $release"
assets=$(curl -s https://api.github.com/repos/NexaAI/${repo_name}/releases/tags/$release | jq -r .assets)
# Get release version from release ie v0.1.0-cu121 -> v0.1.0
release_version=$(echo $release | grep -oE "^[v]?[0-9]+\.[0-9]+\.[0-9]+")

# Extract full release version without removing any segments
release_version=$(echo $release | grep -oE "^[v]?[0-9]+\.[0-9]+\.[0-9]+(\.[0-9]+)?(-[a-zA-Z0-9]+)?$")

# Debugging output for each release
echo "Extracted version: $release_version"
echo "Assets found for release $release_version:"
echo $assets | jq -r .[].browser_download_url

echo " <h2>$release_version</h2>" >> index.html
for asset in $(echo $assets | jq -r .[].browser_download_url); do
if [[ $asset == *".whl" ]]; then
echo "Adding wheel to index: $asset"
echo " <a href=\"$asset\">$asset</a>" >> index.html
echo " <br>" >> index.html
else
echo "Skipping non-wheel asset: $asset"
fi
done
done

echo "Closing HTML tags in index.html"
echo " </body>" >> index.html
echo "</html>" >> index.html
echo "" >> index.html

# Extract the version from the output_dir (e.g., "cpu" from "index/whl/cpu")
version=$(basename "$output_dir")
echo "Extracted version from output directory: $version"

# If this is the CPU version, create the root index.html
if [ "$version" == "cpu" ]; then
echo "Creating root index.html since version is CPU"

# Return to original directory
popd
popd

root_dir=$(dirname "$output_dir")
echo "Root directory: $root_dir"
echo "Creating index.html in root directory"

echo "<!DOCTYPE html>" > "$root_dir/index.html"
echo "<html>" >> "$root_dir/index.html"
echo " <head></head>" >> "$root_dir/index.html"
Expand All @@ -90,4 +122,6 @@ if [ "$version" == "cpu" ]; then
echo " <a href=\"cu124/\">CUDA 12.4</a><br>" >> "$root_dir/index.html"
echo " </body>" >> "$root_dir/index.html"
echo "</html>" >> "$root_dir/index.html"
fi
fi

echo "Script execution completed."

0 comments on commit b7c2fdf

Please sign in to comment.