|
| 1 | +name: Build Windows Executable |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - dev |
| 8 | + tags: |
| 9 | + - 'v*' |
| 10 | + pull_request: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + - dev |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +jobs: |
| 17 | + build-windows: |
| 18 | + runs-on: windows-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout code |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Set up Python 3.11 |
| 25 | + uses: actions/setup-python@v5 |
| 26 | + with: |
| 27 | + python-version: '3.11' |
| 28 | + cache: 'pip' |
| 29 | + |
| 30 | + - name: Install dependencies |
| 31 | + run: | |
| 32 | + python -m pip install --upgrade pip |
| 33 | + pip install -r requirements.txt |
| 34 | + pip install pyinstaller |
| 35 | +
|
| 36 | + - name: Build executable |
| 37 | + run: | |
| 38 | + pyinstaller --clean TranslateBook.spec |
| 39 | +
|
| 40 | + - name: Get executable size |
| 41 | + id: exe_info |
| 42 | + shell: pwsh |
| 43 | + run: | |
| 44 | + $size = (Get-Item dist\TranslateBook.exe).Length |
| 45 | + $sizeMB = [math]::Round($size / 1MB, 2) |
| 46 | + echo "size_bytes=$size" >> $env:GITHUB_OUTPUT |
| 47 | + echo "size_mb=$sizeMB" >> $env:GITHUB_OUTPUT |
| 48 | +
|
| 49 | + - name: Create release archive |
| 50 | + shell: pwsh |
| 51 | + run: | |
| 52 | + # Create a release folder with the executable and readme |
| 53 | + New-Item -ItemType Directory -Path release -Force |
| 54 | + Copy-Item dist\TranslateBook.exe release\ |
| 55 | +
|
| 56 | + # Create a simple README for the release |
| 57 | + $readme = @" |
| 58 | + # TranslateBook Windows Executable |
| 59 | +
|
| 60 | + ## Installation |
| 61 | +
|
| 62 | + 1. Extract TranslateBook.exe to a folder of your choice |
| 63 | + 2. Install Ollama from https://ollama.ai (required for local LLM) |
| 64 | + 3. Double-click TranslateBook.exe to start the server |
| 65 | + 4. Open your browser to http://localhost:5000 |
| 66 | +
|
| 67 | + ## First Run |
| 68 | +
|
| 69 | + On first run, the application will: |
| 70 | + - Create a TranslateBook_Data folder next to the executable |
| 71 | + - Generate a default .env configuration file |
| 72 | + - Create necessary subdirectories (translated_files, checkpoints) |
| 73 | +
|
| 74 | + ## Configuration |
| 75 | +
|
| 76 | + Edit TranslateBook_Data\.env to customize: |
| 77 | + - LLM provider (Ollama, OpenAI, Gemini, OpenRouter) |
| 78 | + - Model selection |
| 79 | + - API keys for cloud providers |
| 80 | + - Server port and host |
| 81 | +
|
| 82 | + ## Usage |
| 83 | +
|
| 84 | + - Web UI: http://localhost:5000 |
| 85 | + - Supported formats: .txt, .epub, .srt |
| 86 | + - Output files: TranslateBook_Data\translated_files\ |
| 87 | +
|
| 88 | + For more information, visit: https://github.com/yourusername/TranslateBookWithLLM |
| 89 | + "@ |
| 90 | +
|
| 91 | + $readme | Out-File -FilePath release\README.txt -Encoding UTF8 |
| 92 | +
|
| 93 | + # Create zip archive |
| 94 | + Compress-Archive -Path release\* -DestinationPath TranslateBook-Windows.zip |
| 95 | +
|
| 96 | + - name: Upload artifact |
| 97 | + uses: actions/upload-artifact@v4 |
| 98 | + with: |
| 99 | + name: TranslateBook-Windows |
| 100 | + path: TranslateBook-Windows.zip |
| 101 | + retention-days: 90 |
| 102 | + |
| 103 | + - name: Upload executable only |
| 104 | + uses: actions/upload-artifact@v4 |
| 105 | + with: |
| 106 | + name: TranslateBook.exe |
| 107 | + path: dist\TranslateBook.exe |
| 108 | + retention-days: 90 |
| 109 | + |
| 110 | + - name: Build summary |
| 111 | + shell: pwsh |
| 112 | + run: | |
| 113 | + echo "### Build Complete! :rocket:" >> $env:GITHUB_STEP_SUMMARY |
| 114 | + echo "" >> $env:GITHUB_STEP_SUMMARY |
| 115 | + echo "**Executable Size:** ${{ steps.exe_info.outputs.size_mb }} MB" >> $env:GITHUB_STEP_SUMMARY |
| 116 | + echo "" >> $env:GITHUB_STEP_SUMMARY |
| 117 | + echo "**Artifacts:**" >> $env:GITHUB_STEP_SUMMARY |
| 118 | + echo "- TranslateBook-Windows.zip (executable + README)" >> $env:GITHUB_STEP_SUMMARY |
| 119 | + echo "- TranslateBook.exe (standalone)" >> $env:GITHUB_STEP_SUMMARY |
| 120 | +
|
| 121 | + - name: Create Release (on tag) |
| 122 | + if: startsWith(github.ref, 'refs/tags/v') |
| 123 | + uses: softprops/action-gh-release@v1 |
| 124 | + with: |
| 125 | + files: TranslateBook-Windows.zip |
| 126 | + body: | |
| 127 | + ## Windows Executable Release |
| 128 | +
|
| 129 | + ### Installation |
| 130 | + 1. Download and extract TranslateBook-Windows.zip |
| 131 | + 2. Install [Ollama](https://ollama.ai) (required for local LLM) |
| 132 | + 3. Run TranslateBook.exe |
| 133 | + 4. Open http://localhost:5000 in your browser |
| 134 | +
|
| 135 | + ### What's Included |
| 136 | + - Single-file Windows executable (no Python installation required) |
| 137 | + - Auto-generated configuration on first run |
| 138 | + - Support for .txt, .epub, .srt translation |
| 139 | +
|
| 140 | + ### System Requirements |
| 141 | + - Windows 10/11 (64-bit) |
| 142 | + - Ollama installed for local LLM support |
| 143 | + - Or API keys for cloud providers (OpenAI, Gemini, OpenRouter) |
| 144 | +
|
| 145 | + **Size:** ${{ steps.exe_info.outputs.size_mb }} MB |
| 146 | + draft: false |
| 147 | + prerelease: false |
| 148 | + env: |
| 149 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments