Build Rust Windows Binary #20
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: Build Rust Windows Binary | |
| # Manual trigger only | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version tag (e.g., v1.0.0)' | |
| required: false | |
| default: 'latest' | |
| jobs: | |
| build-windows: | |
| runs-on: windows-latest | |
| timeout-minutes: 30 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Setup Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| - name: Rust cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: visolingua-rust/src-tauri | |
| cache-on-failure: false | |
| save-if: false | |
| - name: Clean build cache | |
| working-directory: visolingua-rust | |
| run: | | |
| if (Test-Path "src-tauri/target") { | |
| Remove-Item -Recurse -Force "src-tauri/target" | |
| } | |
| - name: Install npm dependencies | |
| working-directory: visolingua-rust | |
| run: npm install | |
| - name: Build Tauri application | |
| working-directory: visolingua-rust | |
| run: npm run tauri build | |
| - name: Verify build | |
| working-directory: visolingua-rust | |
| run: | | |
| if (Test-Path "src-tauri/target/release/visolingua.exe") { | |
| Write-Host "✅ Build successful!" | |
| $size = (Get-Item "src-tauri/target/release/visolingua.exe").Length / 1MB | |
| Write-Host "📏 Binary size: $($size.ToString('F1')) MB" | |
| } else { | |
| Write-Host "❌ Build failed - executable not found" | |
| exit 1 | |
| } | |
| # Check for NSIS installer | |
| $installer = Get-ChildItem -Path "src-tauri/target/release/bundle/nsis" -Filter "*-setup.exe" -ErrorAction SilentlyContinue | Select-Object -First 1 | |
| if ($installer) { | |
| Write-Host "✅ NSIS installer found: $($installer.Name)" | |
| $size = $installer.Length / 1MB | |
| Write-Host "📏 Installer size: $($size.ToString('F1')) MB" | |
| } else { | |
| Write-Host "⚠️ No NSIS installer found (bundle may be disabled)" | |
| } | |
| - name: Create portable package | |
| working-directory: visolingua-rust | |
| run: | | |
| # Create portable directory | |
| $portableDir = "VisoLingua-Rust-Portable" | |
| New-Item -ItemType Directory -Path $portableDir -Force | |
| # Copy files | |
| Copy-Item "src-tauri/target/release/visolingua.exe" "$portableDir/" | |
| Copy-Item "README.md" "$portableDir/" -ErrorAction SilentlyContinue | |
| Copy-Item "SETUP.md" "$portableDir/" -ErrorAction SilentlyContinue | |
| Copy-Item "BUILD_WINDOWS.md" "$portableDir/" -ErrorAction SilentlyContinue | |
| # Create config template | |
| $configDir = "$portableDir/config" | |
| New-Item -ItemType Directory -Path $configDir -Force | |
| @" | |
| # VisoLingua Configuration | |
| # Edit this file with your API keys | |
| [llm] | |
| provider = "gemini" # Options: gemini, openai, ollama | |
| gemini_model = "gemini-2.0-flash-exp" | |
| openai_model = "gpt-4o-mini" | |
| ollama_url = "http://localhost:11434" | |
| ollama_model = "llava" | |
| [api_keys] | |
| gemini = "" # Get from: https://aistudio.google.com/ | |
| openai = "" # Get from: https://platform.openai.com/ | |
| [translation] | |
| target_language = "German" | |
| [ui] | |
| overlay_transparency = "0.3" | |
| "@ | Out-File -FilePath "$configDir/config_sample.toml" -Encoding UTF8 | |
| # Create launcher script | |
| @" | |
| @echo off | |
| echo Starting VisoLingua... | |
| echo. | |
| echo Configuration file location: | |
| echo %APPDATA%\visolingua\config.toml | |
| echo. | |
| echo Debug log location: | |
| echo %TEMP%\visolingua-rust-debug.log | |
| echo. | |
| REM Check if config exists | |
| if not exist "%APPDATA%\visolingua\config.toml" ( | |
| echo First run detected - creating default config... | |
| mkdir "%APPDATA%\visolingua" 2>nul | |
| copy "config\config_sample.toml" "%APPDATA%\visolingua\config.toml" | |
| echo. | |
| echo IMPORTANT: Edit the config file and add your API keys: | |
| echo %APPDATA%\visolingua\config.toml | |
| echo. | |
| pause | |
| ) | |
| start "" visolingua.exe > "%TEMP%\visolingua-rust-debug.log" 2>&1 | |
| "@ | Out-File -FilePath "$portableDir/Start-VisoLingua.bat" -Encoding ASCII | |
| # Create README | |
| @" | |
| # VisoLingua Rust - Windows Portable | |
| ## Quick Start | |
| 1. Run "Start-VisoLingua.bat" | |
| 2. On first run, edit the config file that opens | |
| 3. Add your API key (Gemini or OpenAI) | |
| 4. Save and restart | |
| ## Configuration | |
| Config file location: %APPDATA%\visolingua\config.toml | |
| Get API keys: | |
| - Gemini (Free): https://aistudio.google.com/ | |
| - OpenAI (Paid): https://platform.openai.com/ | |
| ## Usage | |
| 1. Position the red overlay window over text | |
| 2. Click inside to capture and translate | |
| 3. View results in the popup window | |
| 4. Use "Ask AI" to ask questions about translations | |
| ## System Requirements | |
| - Windows 10 or later | |
| - WebView2 Runtime (usually pre-installed on Windows 11) | |
| If WebView2 is missing, download from: | |
| https://go.microsoft.com/fwlink/p/?LinkId=2124703 | |
| ## Size Comparison | |
| - Rust version: ~8-10 MB | |
| - Python version: ~50 MB | |
| 80% smaller, native performance! | |
| "@ | Out-File -FilePath "$portableDir/README.txt" -Encoding UTF8 | |
| Write-Host "✅ Portable package created: $portableDir" | |
| - name: Create ZIP archive | |
| working-directory: visolingua-rust | |
| run: | | |
| Compress-Archive -Path "VisoLingua-Rust-Portable" -DestinationPath "VisoLingua-Rust-Windows.zip" | |
| $size = (Get-Item "VisoLingua-Rust-Windows.zip").Length / 1MB | |
| Write-Host "✅ ZIP archive created: $($size.ToString('F1')) MB" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: VisoLingua-Rust-Windows | |
| path: | | |
| visolingua-rust/VisoLingua-Rust-Windows.zip | |
| visolingua-rust/src-tauri/target/release/visolingua.exe | |
| visolingua-rust/src-tauri/target/release/bundle/nsis/*-setup.exe | |
| - name: Create Release | |
| if: github.event.inputs.version != 'latest' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: rust-${{ github.event.inputs.version }} | |
| name: VisoLingua Rust ${{ github.event.inputs.version }} | |
| draft: false | |
| prerelease: false | |
| body: | | |
| # VisoLingua Rust ${{ github.event.inputs.version }} | |
| ## 🚀 Native Rust + Tauri Version | |
| ### ✨ Advantages: | |
| - **80% smaller** than Python version (~8 MB vs ~50 MB) | |
| - **Native performance** - no Python runtime needed | |
| - **No antivirus false positives** - native compilation | |
| - **Same features** - Screenshot, Translation, Ask AI | |
| ### 📦 Downloads: | |
| - **VisoLingua-Rust-Windows.zip**: Complete portable package (recommended) | |
| - **visolingua.exe**: Standalone binary | |
| ### 🔧 Quick Setup: | |
| 1. Download and extract ZIP | |
| 2. Run "Start-VisoLingua.bat" | |
| 3. Add API key in config file | |
| 4. Restart and use! | |
| ### 📋 Requirements: | |
| - Windows 10 or later | |
| - WebView2 Runtime (pre-installed on Win 11) | |
| ### 🔑 Get API Keys: | |
| - **Gemini** (Free): https://aistudio.google.com/ | |
| - **OpenAI** (Paid): https://platform.openai.com/ | |
| files: | | |
| visolingua-rust/VisoLingua-Rust-Windows.zip | |
| visolingua-rust/src-tauri/target/release/visolingua.exe | |
| visolingua-rust/src-tauri/target/release/bundle/nsis/*-setup.exe | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |