name: Nightly Build on: schedule: - cron: '0 8 * * *' # UTC time workflow_dispatch: permissions: contents: write jobs: tag: name: Tag dev branch if dev version runs-on: ubuntu-latest if: github.repository == 'mit-han-lab/nunchaku' outputs: need_build: ${{ steps.check.outputs.need_build }} tag_name: ${{ steps.tag.outputs.tag_name }} steps: - name: Checkout dev branch uses: actions/checkout@v4 with: fetch-depth: 0 ref: dev - 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 == 'mit-han-lab/nunchaku' strategy: matrix: python: ["3.10", "3.11", "3.12"] torch: ["2.5", "2.6", "2.7"] 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 }}" == "2.7" ]]; then cuda_version="12.8" else cuda_version="12.4" fi bash scripts/build_linux_wheel.sh ${{ matrix.python }} ${{ matrix.torch }} $cuda_version - 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() && github.repository == 'mit-han-lab/nunchaku' run: bash scripts/linux_cleanup.sh windows-wheels: name: Build the windows nightly wheels runs-on: [self-hosted, windows-build] needs: tag if: needs.tag.outputs.need_build == 'true' && github.repository == 'mit-han-lab/nunchaku' strategy: matrix: python: ["3.10", "3.11", "3.12"] torch: ["2.5", "2.6", "2.7"] 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 shell: cmd run: | SET TORCH_VERSION=${{ matrix.torch }} IF "%TORCH_VERSION%"=="2.7" ( SET CUDA_VERSION=12.8 ) ELSE ( SET CUDA_VERSION=12.4 ) call C:\Users\muyangl\miniconda3\condabin\activate.bat activate call scripts\build_windows_wheel.cmd ${{ matrix.python }} %TORCH_VERSION% %CUDA_VERSION% - 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 }}