Nightly Builds #151
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nightly Builds | |
| on: | |
| schedule: | |
| - cron: "0 4 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| check: | |
| name: Check for new commits | |
| runs-on: ubuntu-latest | |
| outputs: | |
| should_build: ${{ steps.check.outputs.should_build }} | |
| sha: ${{ steps.check.outputs.sha }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for commits in last 24 hours | |
| id: check | |
| run: | | |
| SHA=$(git rev-parse HEAD) | |
| echo "sha=$SHA" >> "$GITHUB_OUTPUT" | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| echo "should_build=true" >> "$GITHUB_OUTPUT" | |
| echo "Manual trigger — building regardless of commit age" | |
| exit 0 | |
| fi | |
| RECENT=$(git log --since="24 hours ago" --oneline) | |
| if [ -n "$RECENT" ]; then | |
| echo "should_build=true" >> "$GITHUB_OUTPUT" | |
| echo "New commits found:" | |
| echo "$RECENT" | |
| else | |
| echo "should_build=false" >> "$GITHUB_OUTPUT" | |
| echo "No new commits in the last 24 hours — skipping build" | |
| fi | |
| build: | |
| name: Build ${{ matrix.target }} | |
| needs: check | |
| if: needs.check.outputs.should_build == 'true' | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - target: x86_64-unknown-linux-gnu | |
| runner: ubuntu-latest | |
| - target: aarch64-unknown-linux-gnu | |
| runner: ubuntu-latest | |
| cross: true | |
| - target: x86_64-apple-darwin | |
| runner: macos-latest | |
| - target: aarch64-apple-darwin | |
| runner: macos-latest | |
| - target: x86_64-pc-windows-msvc | |
| runner: windows-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Patch path dependencies for standalone build | |
| if: runner.os != 'Windows' | |
| run: | | |
| # ROOT CAUSE: Cargo.toml has [patch.crates-io] with local path | |
| # overrides (apr-cli, aprender, trueno, etc.) that don't exist on CI runners. | |
| # This was the actual source of "Unable to update ../aprender/crates/apr-cli". | |
| # Remove the entire [patch.crates-io] section from Cargo.toml | |
| sed -i.bak '/^\[patch\.crates-io\]/,$ d' Cargo.toml | |
| # Remove path = "../aprender" from aprender dependency lines | |
| sed -i.bak 's|, path = "\.\./aprender"||g' Cargo.toml | |
| # Fix apr-cli version: match current crates.io reality | |
| sed -i.bak 's|apr-cli = { version = "[0-9.]*"|apr-cli = { version = "0.51"|g' Cargo.toml | |
| rm -f Cargo.toml.bak | |
| rm -f .cargo/config.toml | |
| # Keep the committed Cargo.lock: the build below runs with --locked so the | |
| # nightly fails loudly on any unexpected lockfile drift instead of silently | |
| # resolving new dependency versions every run (hermetic, reproducible builds). | |
| echo "=== Patched Cargo.toml dependency sections ===" | |
| grep -n 'aprender\|apr-cli\|\[patch' Cargo.toml || true | |
| - name: Patch path dependencies for standalone build | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| # ROOT CAUSE: Cargo.toml has [patch.crates-io] with local path | |
| # overrides that don't exist on CI runners. | |
| $content = Get-Content Cargo.toml -Raw | |
| # Remove the entire [patch.crates-io] section | |
| $content = $content -replace '(?ms)\[patch\.crates-io\].*\z', '' | |
| # Remove path = "../aprender" from aprender dependency lines | |
| $content = $content -replace ', path = "\.\./aprender"', '' | |
| # Fix apr-cli version: match current crates.io reality | |
| $content = $content -replace 'apr-cli = \{ version = "[0-9.]+"', 'apr-cli = { version = "0.51"' | |
| Set-Content Cargo.toml -Value $content.TrimEnd() -NoNewline | |
| Remove-Item -ErrorAction SilentlyContinue .cargo/config.toml | |
| # Keep the committed Cargo.lock: the build below runs with --locked so the | |
| # nightly fails loudly on any unexpected lockfile drift instead of silently | |
| # resolving new dependency versions every run (hermetic, reproducible builds). | |
| Write-Host "=== Patched Cargo.toml dependency sections ===" | |
| Select-String -Path Cargo.toml -Pattern 'aprender|apr-cli|\[patch' | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Ensure target is installed | |
| run: rustup target add ${{ matrix.target }} | |
| - name: Install cross (Linux ARM) | |
| if: matrix.cross | |
| run: cargo install cross --git https://github.com/cross-rs/cross | |
| - name: Build (cross) | |
| if: matrix.cross | |
| env: | |
| CROSS_NO_WARNINGS: "0" | |
| run: cross build --locked --release --target ${{ matrix.target }} --features cli | |
| - name: Build | |
| if: ${{ !matrix.cross }} | |
| run: cargo build --locked --release --target ${{ matrix.target }} --features cli | |
| - name: Package (unix) | |
| if: matrix.target != 'x86_64-pc-windows-msvc' | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| tar czf ../../../whisper-apr-${{ matrix.target }}.tar.gz whisper-apr | |
| cd ../../.. | |
| - name: Package (windows) | |
| if: matrix.target == 'x86_64-pc-windows-msvc' | |
| shell: bash | |
| run: | | |
| cd target/${{ matrix.target }}/release | |
| 7z a ../../../whisper-apr-${{ matrix.target }}.zip whisper-apr.exe | |
| cd ../../.. | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: whisper-apr-${{ matrix.target }} | |
| path: whisper-apr-${{ matrix.target }}.* | |
| release: | |
| name: Release | |
| needs: [check, build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/download-artifact@v8 | |
| with: | |
| path: artifacts | |
| merge-multiple: true | |
| - name: Delete existing nightly release | |
| run: gh release delete nightly --yes --cleanup-tag 2>/dev/null || true | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: nightly | |
| name: Nightly Build | |
| prerelease: true | |
| make_latest: false | |
| body: | | |
| Automated nightly build from `main`. | |
| **Commit:** ${{ needs.check.outputs.sha }} | |
| > This is a pre-release build and may be unstable. | |
| files: artifacts/* |