Skip to content

Commit

Permalink
ci: Action to build PEP 503 Simple Repository from github releases
Browse files Browse the repository at this point in the history
  • Loading branch information
abetlen committed Mar 4, 2024
1 parent aed504c commit 9dbda11
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/wheels-index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Wheels Index

on:
# Trigger on any new release
release:
types: [published]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Build
run: |
mkdir -p index/whl/cpu
./scripts/releases-to-pep-503.sh index/whl/cpu
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: "index"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
52 changes: 52 additions & 0 deletions scripts/releases-to-pep-503.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

# Get output directory
output_dir=$1

# Create output directory
mkdir -p $output_dir

# Change to output directory
pushd $output_dir

# Create an index html file
echo "<!DOCTYPE html>" > index.html
echo "<html>" >> index.html
echo " <head></head>" >> index.html
echo " <body>" >> index.html
echo " <a href=\"ggml-python/\">ggml-python</a>" >> index.html
echo " <br>" >> index.html
echo " </body>" >> index.html
echo "</html>" >> index.html
echo "" >> index.html

# Create ggml-python directory
mkdir -p ggml-python

# Change to ggml-python directory
pushd ggml-python

# Create an index html file
echo "<!DOCTYPE html>" > index.html
echo "<html>" >> index.html
echo " <body>" >> index.html
echo " <h1>Links for ggml-python</h1>" >> index.html

# Get all releases
releases=$(curl -s https://api.github.com/repos/abetlen/ggml-python/releases | jq -r .[].tag_name)

# For each release, get all assets
for release in $releases; do
assets=$(curl -s https://api.github.com/repos/abetlen/ggml-python/releases/tags/$release | jq -r .assets)
echo " <h2>$release</h2>" >> index.html
for asset in $(echo $assets | jq -r .[].browser_download_url); do
if [[ $asset == *".whl" ]]; then
echo " <a href=\"$asset\">$asset</a>" >> index.html
echo " <br>" >> index.html
fi
done
done

echo " </body>" >> index.html
echo "</html>" >> index.html
echo "" >> index.html

0 comments on commit 9dbda11

Please sign in to comment.