-
-
Notifications
You must be signed in to change notification settings - Fork 68
228 lines (180 loc) · 7.39 KB
/
build-macos.yml
File metadata and controls
228 lines (180 loc) · 7.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
name: Build macOS Executable
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
build-macos:
strategy:
fail-fast: false
matrix:
include:
- os: macos-15-intel
arch: x86_64
artifact_suffix: Intel
- os: macos-14
arch: arm64
artifact_suffix: AppleSilicon
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build executable
run: |
pyinstaller --clean build/macos/TranslateBook-macOS.spec
- name: Get executable info
id: exe_info
run: |
SIZE_BYTES=$(stat -f%z dist/TranslateBook)
SIZE_MB=$(echo "scale=2; $SIZE_BYTES / 1048576" | bc)
echo "size_bytes=$SIZE_BYTES" >> $GITHUB_OUTPUT
echo "size_mb=$SIZE_MB" >> $GITHUB_OUTPUT
ARCH=$(file dist/TranslateBook | grep -o 'arm64\|x86_64')
echo "arch=$ARCH" >> $GITHUB_OUTPUT
- name: Create release archive
run: |
# Create a release folder with the executable and readme
mkdir -p release
# Copy executable
cp dist/TranslateBook release/
# Make sure it's executable
chmod +x release/TranslateBook
# Create a README for the release
cat > release/README.txt << 'EOF'
# TranslateBook macOS Executable
## Quick Start
1. Extract TranslateBook to a folder of your choice
2. Open Terminal and run: ./TranslateBook
3. Open your browser to http://localhost:5000
4. Choose your LLM provider (see below)
## First Launch - Security Authorization
macOS will block the app on first launch. To authorize it:
1. Double-click TranslateBook - macOS will show a warning
2. Open System Settings > Privacy & Security
3. Scroll down and click "Open Anyway" next to the TranslateBook message
4. Click "Open" in the confirmation dialog
This only needs to be done once.
## LLM Providers
You need at least one LLM provider to translate:
- Poe (Recommended) - Easy setup, multiple AI models: https://poe.com/api_key
- Ollama (Local) - Free, runs on your machine: https://ollama.com
- OpenRouter - 200+ cloud models: https://openrouter.ai/keys
- OpenAI - GPT models: https://platform.openai.com/api-keys
- Mistral - French AI lab: https://console.mistral.ai/api-keys
- DeepSeek - Chinese AI lab: https://platform.deepseek.com/api_keys
- Gemini - Google AI: https://aistudio.google.com/apikey
For local translation with Ollama:
1. Install Ollama from https://ollama.com
2. Download a model: ollama pull qwen3:14b
## Choosing the Best Model for Your Language
Different models perform better for different target languages!
See our comprehensive benchmarks to find the best model:
https://github.com/hydropix/TranslateBooksWithLLMs/wiki
## First Run
On first run, the application will:
- Create a TranslateBook_Data folder next to the executable
- Generate a default .env configuration file
- Create necessary subdirectories (translated_files, checkpoints)
## Configuration
Edit TranslateBook_Data/.env to customize:
- LLM provider and model selection
- API keys for cloud providers
- Server port and host
## Usage
- Web UI: http://localhost:5000
- Supported formats: .txt, .epub, .srt, .docx, .odt
- Output files: TranslateBook_Data/translated_files/
## Links
- Full Documentation: https://github.com/hydropix/TranslateBooksWithLLMs
- Model Benchmarks: https://github.com/hydropix/TranslateBooksWithLLMs/wiki
- Report Issues: https://github.com/hydropix/TranslateBooksWithLLMs/issues
- OpenRouter Models: https://openrouter.ai/models
EOF
# Create zip archive
cd release
zip -r ../TranslateBook-macOS-${{ matrix.artifact_suffix }}.zip .
cd ..
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: TranslateBook-macOS-${{ matrix.artifact_suffix }}
path: TranslateBook-macOS-${{ matrix.artifact_suffix }}.zip
retention-days: 90
- name: Upload executable only
uses: actions/upload-artifact@v4
with:
name: TranslateBook-${{ matrix.artifact_suffix }}
path: dist/TranslateBook
retention-days: 90
- name: Build summary
run: |
echo "### Build Complete! :rocket:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Platform:** macOS ${{ matrix.artifact_suffix }} (${{ matrix.arch }})" >> $GITHUB_STEP_SUMMARY
echo "**Executable Size:** ${{ steps.exe_info.outputs.size_mb }} MB" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Artifacts:**" >> $GITHUB_STEP_SUMMARY
echo "- TranslateBook-macOS-${{ matrix.artifact_suffix }}.zip (executable + README)" >> $GITHUB_STEP_SUMMARY
echo "- TranslateBook (standalone)" >> $GITHUB_STEP_SUMMARY
create-release:
needs: build-macos
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: TranslateBook-macOS-*
merge-multiple: false
- name: List downloaded files
run: |
ls -la
find . -name "*.zip" -type f
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: |
TranslateBook-macOS-Intel/TranslateBook-macOS-Intel.zip
TranslateBook-macOS-AppleSilicon/TranslateBook-macOS-AppleSilicon.zip
body: |
## macOS Executable Release
### Downloads
- **TranslateBook-macOS-AppleSilicon.zip** - For Apple Silicon Macs (M1/M2/M3/M4)
- **TranslateBook-macOS-Intel.zip** - For Intel-based Macs
### Installation
1. Download the appropriate version for your Mac
2. Extract the zip file
3. Install [Ollama](https://ollama.ai) (required for local LLM)
4. Open Terminal and run `./TranslateBook`
5. Open http://localhost:5000 in your browser
### First Launch - Security Authorization
macOS will block the app on first launch:
1. Double-click TranslateBook - macOS shows a warning
2. Open **System Settings > Privacy & Security**
3. Click **"Open Anyway"** next to the TranslateBook message
This only needs to be done once.
### What's Included
- Single-file macOS executable (no Python installation required)
- Auto-generated configuration on first run
- Support for .txt, .epub, .srt translation
### System Requirements
- macOS 11+ (Big Sur or later)
- Ollama installed for local LLM support
- Or API keys for cloud providers (OpenAI, Gemini, OpenRouter)
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}