Skip to content

Build and Publish Wheel to GitHub Pages #13

Build and Publish Wheel to GitHub Pages

Build and Publish Wheel to GitHub Pages #13

Workflow file for this run

name: Build and Publish Wheel to GitHub Pages
on:
workflow_dispatch:
inputs:
python_version:
description: 'Python version to use for the build'
required: true
default: '3.10'
tag_name:
description: 'Release tag (e.g., v0.1.0)'
required: true
default: 'v0.1.0'
jobs:
build_and_publish:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ github.event.inputs.python_version }}
- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build wheel
run: python -m build --wheel
- name: Get wheel filename
id: get_filename
run: |
whl_file=$(ls dist/*.whl)
whl_name=$(basename "$whl_file")
echo "whl_file=$whl_file" >> $GITHUB_OUTPUT
echo "whl_name=$whl_name" >> $GITHUB_OUTPUT
- name: Prepare gh-pages content
run: |
mkdir -p public/
cp "${{ steps.get_filename.outputs.whl_file }}" public/
# Optional: create index.html for a browsable listing
echo "<html><body><a href='${{ steps.get_filename.outputs.whl_name }}'>${{ steps.get_filename.outputs.whl_name }}</a></body></html>" > public/index.html
- name: Publish to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
publish_branch: gh-pages
commit_message: "Publish wheel ${{ steps.get_filename.outputs.whl_name }} for ${{ github.event.inputs.tag_name }}"