name: Build Windows on: push: branches: [main] tags: ["v*"] pull_request: branches: [main] env: PYTHON_VERSION: "3.11" NODE_VERSION: "20" TARGET: x86_64-pc-windows-msvc jobs: build: name: Build (Windows) runs-on: windows-latest steps: - uses: actions/checkout@v4 # ── Python sidecar ── - name: Install uv shell: powershell run: | if (Get-Command uv -ErrorAction SilentlyContinue) { Write-Host "uv already installed: $(uv --version)" } else { irm https://astral.sh/uv/install.ps1 | iex echo "$env:USERPROFILE\.local\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append } - name: Install ffmpeg shell: powershell run: choco install ffmpeg -y - name: Set up Python shell: powershell run: uv python install ${{ env.PYTHON_VERSION }} - name: Build sidecar shell: powershell working-directory: python run: uv run --python ${{ env.PYTHON_VERSION }} python build_sidecar.py --cpu-only - name: Package sidecar for Tauri shell: powershell run: | Compress-Archive -Path python\dist\voice-to-notes-sidecar\* -DestinationPath src-tauri\sidecar.zip # ── Tauri app ── - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: ${{ env.NODE_VERSION }} - name: Install Rust stable shell: powershell run: | if (Get-Command rustup -ErrorAction SilentlyContinue) { rustup default stable } else { Invoke-WebRequest -Uri https://win.rustup.rs/x86_64 -OutFile rustup-init.exe .\rustup-init.exe -y --default-toolchain stable echo "$env:USERPROFILE\.cargo\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append } - name: Install npm dependencies shell: powershell run: npm ci - name: Build Tauri app shell: powershell run: npm run tauri build # ── Release ── - name: Upload to release if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') shell: powershell env: BUILD_TOKEN: ${{ secrets.BUILD_TOKEN }} run: | $REPO_API = "${{ github.server_url }}/api/v1/repos/${{ github.repository }}" $Headers = @{ "Authorization" = "token $env:BUILD_TOKEN" } # Use version tag for tag pushes, "latest" for main $REF = "${{ github.ref }}" if ($REF.StartsWith("refs/tags/")) { $TAG = $REF.Replace("refs/tags/", "") $RELEASE_NAME = "Voice to Notes ${TAG}" $PRERELEASE = $false } else { $TAG = "latest" $RELEASE_NAME = "Voice to Notes (Latest Build)" $PRERELEASE = $true } Write-Host "Release tag: ${TAG}" try { $release = Invoke-RestMethod -Uri "${REPO_API}/releases/tags/${TAG}" -Headers $Headers -ErrorAction Stop $RELEASE_ID = $release.id } catch { $body = @{ tag_name = $TAG name = $RELEASE_NAME body = "Automated build." draft = $false prerelease = $PRERELEASE } | ConvertTo-Json $release = Invoke-RestMethod -Uri "${REPO_API}/releases" -Method Post -Headers $Headers -ContentType "application/json" -Body $body $RELEASE_ID = $release.id } Write-Host "Release ID: ${RELEASE_ID}" Get-ChildItem -Path src-tauri\target\release\bundle -Recurse -Include *.msi,*-setup.exe | ForEach-Object { $filename = $_.Name $encodedName = [System.Uri]::EscapeDataString($filename) $size = [math]::Round($_.Length / 1MB, 1) Write-Host "Uploading ${filename} (${size} MB)..." try { $assets = Invoke-RestMethod -Uri "${REPO_API}/releases/${RELEASE_ID}/assets" -Headers $Headers $existing = $assets | Where-Object { $_.name -eq $filename } if ($existing) { Invoke-RestMethod -Uri "${REPO_API}/releases/${RELEASE_ID}/assets/$($existing.id)" -Method Delete -Headers $Headers } } catch {} # Use curl for streaming upload (Invoke-RestMethod fails on large files) $uploadUrl = "${REPO_API}/releases/${RELEASE_ID}/assets?name=${encodedName}" $result = curl.exe --fail --silent --show-error ` -X POST ` -H "Authorization: token $env:BUILD_TOKEN" ` -H "Content-Type: application/octet-stream" ` --data-binary "@$($_.FullName)" ` "$uploadUrl" 2>&1 if ($LASTEXITCODE -eq 0) { Write-Host "Upload successful: ${filename}" } else { Write-Host "WARNING: Upload failed for ${filename}: ${result}" } }