Skip to content

Nightly Build

Nightly Build #89

name: Nightly Build
on:
schedule:
- cron: '0 8 * * *' # UTC time
workflow_dispatch:
permissions:
contents: write
jobs:
tag:
name: Check if main branch is a dev version
runs-on: ubuntu-latest
if: github.repository == 'nunchaku-ai/nunchaku'
outputs:
need_build: ${{ steps.check.outputs.need_build }}
tag_name: ${{ steps.tag.outputs.tag_name }}
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Extract version from __version__.py
id: version
run: |
version=$(grep '__version__' nunchaku/__version__.py | sed -E 's/.*"([^"]+)".*/\1/')
echo "Extracted version: $version"
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Determine if build is needed
id: check
run: |
version="${{ steps.version.outputs.version }}"
need_build=false
if [[ "$version" == *dev* ]]; then
echo "Version contains 'dev'"
prefix="v$version"
tag=$(git tag --list "${prefix}*" --sort=-creatordate | head -n 1 || echo "")
if [ -z "$tag" ]; then
echo "No previous tag found."
need_build=true
else
base=$(git rev-parse "$tag")
head=$(git rev-parse HEAD)
if [ "$base" != "$head" ]; then
echo "New commits found since $tag"
need_build=true
else
echo "No new commits since $tag"
fi
fi
else
echo "Version does not contain 'dev'"
fi
echo "need_build=$need_build" >> "$GITHUB_OUTPUT"
- name: Set tag name
id: tag
if: steps.check.outputs.need_build == 'true'
run: |
today=$(date -u +"%Y%m%d")
tag_name="v${{ steps.version.outputs.version }}$today"
echo "tag_name=$tag_name"
echo "tag_name=$tag_name" >> "$GITHUB_OUTPUT"
- name: Create and push tag
if: steps.check.outputs.need_build == 'true'
run: |
git config user.name "github-actions"
git config user.email "github-actions@users.noreply.github.com"
git tag ${{ steps.tag.outputs.tag_name }}
git push origin ${{ steps.tag.outputs.tag_name }}
- name: Skip tagging (version is not dev or no new commits)
if: steps.check.outputs.need_build == 'false'
run: echo "Version is not a dev version or no new commits. Skipping tag."
linux-wheels:
name: Build the linux nightly wheels
runs-on: [self-hosted, linux-build]
needs: tag
if: needs.tag.outputs.need_build == 'true' && github.repository == 'nunchaku-ai/nunchaku'
strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13"]
torch: ["2.8", "2.9", "2.10", "pre"]
cuda: ["12.8", "13.0"]
exclude:
- torch: "2.8"
cuda: "13.0"
steps:
- name: Checkout to the tag
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.tag.outputs.tag_name }}
submodules: true
- name: Show current commit
run: git log -1 --oneline
- name: Build wheels
run: |
if [[ "${{ matrix.torch }}" == "pre" ]]; then
bash scripts/build_linux_wheel_torch_nightly.sh ${{ matrix.python }} ${{ matrix.torch }} ${{ matrix.cuda }}
else
bash scripts/build_linux_wheel.sh ${{ matrix.python }} ${{ matrix.torch }} ${{ matrix.cuda }}
fi
- name: Upload wheels to GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*.whl
name: Nunchaku Nightly ${{ needs.tag.outputs.tag_name }}
tag_name: ${{ needs.tag.outputs.tag_name }}
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Clean up
if: always()
run: bash scripts/linux_cleanup.sh
windows-wheels:
name: Build the windows nightly wheels
runs-on: [self-hosted, win-build]
needs: tag
if: needs.tag.outputs.need_build == 'true' && github.repository == 'nunchaku-ai/nunchaku'
strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13"]
torch: ["2.8", "2.9", "2.10", "pre"]
cuda: ["12.8", "13.0"]
exclude:
- torch: "2.8"
cuda: "13.0"
steps:
- name: Checkout to the tag
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ needs.tag.outputs.tag_name }}
submodules: true
- name: Show current commit
shell: cmd
run: git log -1 --oneline
- name: Build wheels
shell: cmd
run: |
call C:\Users\nunchaku\miniconda3\condabin\activate.bat activate
IF "${{ matrix.torch }}"=="pre" (
call scripts\build_windows_wheel_torch_nightly.cmd ${{ matrix.python }} ${{ matrix.torch }} ${{ matrix.cuda }} 8
) ELSE (
call scripts\build_windows_wheel.cmd ${{ matrix.python }} ${{ matrix.torch }} ${{ matrix.cuda }} 8
)
- name: Upload wheels to GitHub Release
uses: softprops/action-gh-release@v2
with:
files: dist/*.whl
name: Nunchaku Nightly ${{ needs.tag.outputs.tag_name }}
tag_name: ${{ needs.tag.outputs.tag_name }}
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}