Skip to content

Build Latest Wheels #286

Build Latest Wheels

Build Latest Wheels #286

Workflow file for this run

name: Build Latest Wheels
on:
workflow_run:
workflows: ["Unit Tests"]
branches: [main]
types: [completed]
# Prevent concurrent gh-pages deployments
concurrency:
group: gh-pages-deploy
cancel-in-progress: false
jobs:
# Only run if the Unit Tests workflow succeeded
check-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Check workflow success
run: echo "Unit tests passed, proceeding with wheel build"
build-wheels:
needs: check-success
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, ubuntu-24.04-arm, macos-latest, windows-latest]
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
rust-toolchain: [stable]
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1.17.0
with:
toolchain: ${{ matrix.rust-toolchain }}
- name: Set default Rust toolchain
run: |
rustup update ${{ matrix.rust-toolchain }}
rustup default ${{ matrix.rust-toolchain }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
- name: Install Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- name: Build wheel with maturin
uses: PyO3/maturin-action@v1
with:
command: build
rust-toolchain: ${{ matrix.rust-toolchain }}
args: --release -i python${{ matrix.python-version }}
- name: Upload wheel artifact
uses: actions/upload-artifact@v7
with:
name: wheel-${{ matrix.os }}-py${{ matrix.python-version }}
path: target/wheels/*.whl
retention-days: 7
build-sdist:
needs: check-success
runs-on: ubuntu-latest
env:
RUST_TOOLCHAIN: stable
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1.17.0
with:
toolchain: ${{ env.RUST_TOOLCHAIN }}
- name: Set default Rust toolchain
run: |
rustup update ${{ env.RUST_TOOLCHAIN }}
rustup default ${{ env.RUST_TOOLCHAIN }}
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
- name: Install Python 3.12
run: uv python install 3.12
- name: Create virtual environment
run: uv venv -p 3.12
- name: Activate virtual environment
run: source .venv/bin/activate
- name: Install build
run: uv pip install -U build
- name: Build source distribution
run: uv run python -m build --sdist
- name: Upload sdist artifact
uses: actions/upload-artifact@v7
with:
name: sdist
path: dist/*.tar.gz
retention-days: 7
create-or-update-release:
needs: [build-wheels, build-sdist]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
- name: Create or update 'latest' release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Check if 'latest' release exists
if gh release view latest >/dev/null 2>&1; then
echo "Release 'latest' already exists"
else
echo "Creating new 'latest' pre-release"
gh release create latest \
--title "Latest Development Build" \
--notes "Automated build from the latest main branch. These are development builds and may be unstable.
## Installation
To install the latest development version:
\`\`\`bash
pip install brahe --extra-index-url https://docs.brahe.space/simple/
\`\`\`
Or download wheels directly from the assets below.
**Note:** This is a rolling release that is automatically updated with each push to main." \
--prerelease
fi
upload-assets:
needs: create-or-update-release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
- name: Download all wheel artifacts
uses: actions/download-artifact@v8
with:
pattern: wheel-*
path: dist-wheels
merge-multiple: true
- name: Download sdist artifact
uses: actions/download-artifact@v8
with:
name: sdist
path: dist-sdist
- name: Combine and rename artifacts
run: |
mkdir -p dist
# Copy and rename wheels to include "latest" instead of version
for wheel in dist-wheels/*.whl; do
if [ -f "$wheel" ]; then
# Extract filename and replace version with "latest"
filename=$(basename "$wheel")
# Replace version pattern (e.g., 0.1.0, 1.2.3) with "latest"
new_filename=$(echo "$filename" | sed -E 's/-[0-9]+\.[0-9]+\.[0-9]+(-|\.whl)/-latest\1/')
cp -v "$wheel" "dist/$new_filename"
fi
done
# Copy and rename sdist to include "latest" instead of version
for sdist in dist-sdist/*.tar.gz; do
if [ -f "$sdist" ]; then
filename=$(basename "$sdist")
# Replace version pattern with "latest"
new_filename=$(echo "$filename" | sed -E 's/-[0-9]+\.[0-9]+\.[0-9]+\.tar\.gz/-latest.tar.gz/')
cp -v "$sdist" "dist/$new_filename"
fi
done
echo "Renamed artifacts:"
ls -lh dist/
- name: Upload assets to latest release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Upload with --clobber to replace existing files
gh release upload latest dist/* --clobber
update-simple-index:
needs: upload-assets
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v7.0.1
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v9.0.0
with:
enable-cache: true
- name: Install Python 3.12
run: uv python install 3.12
- name: Generate simple index
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
uv run --no-sync python scripts/generate_simple_index.py \
--repo ${{ github.repository }} \
--package-name brahe \
--tag latest \
--output simple-index
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4.1.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./simple-index
keep_files: true
destination_dir: .
cname: docs.brahe.space