Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
Generate package index for latest release
Browse files Browse the repository at this point in the history
  • Loading branch information
sasha0552 authored Jun 3, 2024
1 parent d23964f commit b287b6b
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 6 deletions.
87 changes: 87 additions & 0 deletions .ci/update-index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/usr/bin/env python3

import os
import packaging.utils
import requests
import sys

def main():
# Check if the correct number of command-line arguments is provided
if len(sys.argv) != 2:
print(f"Usage: {sys.argv[0]} <repository>")
sys.exit(1)

# Extract the repository path from the command-line arguments
repository = sys.argv[1]

# Fetch releases from the GitHub API for the specified repository
response = requests.get(f"https://api.github.com/repos/{repository}/releases")

# Raise an error if the request was unsuccessful
response.raise_for_status()

# Parse the response JSON
data = response.json()

# Initialize variable to hold the assets of the first non-prerelease
assets = None

# Loop through the releases to find the first non-prerelease
for release in data:
if not release["prerelease"]:
assets = release["assets"]
break

# Dictionary to hold package information
packages = {}

# Process each asset in the release
for asset in assets:
# Get the asset name and download URL
name = asset["name"]
url = asset["browser_download_url"]

# Parse the wheel filename to extract package information
parsed = packaging.utils.parse_wheel_filename(name)

# Extract the package name from the parsed information
package_name = parsed[0]

# Initialize the package entry in the dictionary if not already present
if package_name not in packages:
packages[package_name] = []

# Append the asset information to the package entry
packages[package_name].append((name, url))

# Generate HTML pages for each package
for package_name, wheels in packages.items():
# Create a directory for the package
os.makedirs(f"_site/{package_name}", exist_ok=True)

# Create an index.html file for the package
with open(f"_site/{package_name}/index.html", "w") as file:
file.write("<!DOCTYPE html>")
file.write("<html>")
file.write("<body>")
file.write(f"<h1>Links for {package_name}</h1>")
# Add links to each wheel file
for (wheel_name, wheel_url) in wheels:
file.write(f'<a href="{wheel_url}">{wheel_name}</a><br/>')
file.write("</body>")
file.write("</html>")

# Create the main index.html file
os.makedirs("_site", exist_ok=True)
with open("_site/index.html", "w") as file:
file.write("<!DOCTYPE html>")
file.write("<html>")
file.write("<body>")
# Add links to each package
for package_name in packages.keys():
file.write(f'<a href="{package_name}/">{package_name}</a><br/>')
file.write("</body>")
file.write("</html>")

if __name__ == "__main__":
main()
7 changes: 4 additions & 3 deletions .github/workflows/build-triton.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -43,6 +46,7 @@ jobs:
- name: Create release
uses: softprops/action-gh-release@v2
with:
draft: true
files: wheelhouse/*.whl
tag_name: ${{ github.event.inputs.tag_name }}

Expand All @@ -69,6 +73,3 @@ on:
description: Target tag
required: true
type: string

permissions:
contents: write
7 changes: 4 additions & 3 deletions .github/workflows/build-vllm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ jobs:
build:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down Expand Up @@ -45,6 +48,7 @@ jobs:
- name: Create release
uses: softprops/action-gh-release@v2
with:
draft: true
files: wheelhouse/*.whl
tag_name: ${{ github.event.inputs.tag_name }}

Expand All @@ -71,6 +75,3 @@ on:
description: Target tag
required: true
type: string

permissions:
contents: write
42 changes: 42 additions & 0 deletions .github/workflows/update-index.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Update package index

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
repository: ${{ github.event.inputs.repository }}

- name: Generate package index
run: .ci/update-index.py ${{ github.repository }}

- name: Upload artifact
uses: actions/upload-pages-artifact@v3

deploy:
needs: build
runs-on: ubuntu-latest

environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

permissions:
id-token: write
pages: write

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4

on:
release:
types:
- released

workflow_dispatch:
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_site/

0 comments on commit b287b6b

Please sign in to comment.