Skip to content

Commit 3a27fde

Browse files
committed
build: 优化构建流程并添加模块排除
- 将单行构建命令拆分为多行,提高可读性 - 添加多个模块的排除,减少构建体积 - 修改 macOS 构建流程,只构建当前平台架构 - 为 Linux 添加构建步骤 - 移除创建通用二进制和复制资源文件的步骤
1 parent 97fb030 commit 3a27fde

File tree

1 file changed

+52
-29
lines changed

1 file changed

+52
-29
lines changed

.github/workflows/build.yml

Lines changed: 52 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,24 @@ jobs:
106106
dir .env
107107
dir assets
108108
# 构建
109-
pyinstaller --noconsole --add-data ".env;." --add-data "assets/*;assets" --icon "assets/icon.ico" --name "Text2Voice" main.py
109+
pyinstaller --noconsole \
110+
--add-data ".env;." \
111+
--add-data "assets/*;assets" \
112+
--icon "assets/icon.ico" \
113+
--name "Text2Voice" \
114+
--hidden-import PyQt6.QtCore \
115+
--hidden-import PyQt6.QtGui \
116+
--hidden-import PyQt6.QtWidgets \
117+
--exclude-module matplotlib \
118+
--exclude-module numpy \
119+
--exclude-module PIL \
120+
--exclude-module pandas \
121+
--exclude-module scipy \
122+
--exclude-module tkinter \
123+
--exclude-module PyQt6.QtSvg \
124+
--exclude-module PyQt6.QtNetwork \
125+
--exclude-module PyQt6.QtPrintSupport \
126+
main.py
110127
111128
- name: Install macOS dependencies
112129
if: runner.os == 'macOS'
@@ -141,47 +158,53 @@ jobs:
141158
ls -la .env
142159
ls -la assets
143160
144-
# Intel Mac 构建
145-
echo "Building for Intel Mac..."
146-
ARCH="x86_64" pyinstaller --noconsole \
161+
# 只构建当前平台架构
162+
pyinstaller --noconsole \
147163
--add-data ".env:." \
148164
--add-data "assets/*:assets" \
149165
--icon "assets/icon.icns" \
150-
--name "Text2Voice-Intel" \
151-
--add-binary "${INTEL_QT_PATH}/lib:Qt6" \
152-
--add-binary "${INTEL_QT_PATH}/plugins:Qt6/plugins" \
166+
--name "Text2Voice" \
153167
--hidden-import PyQt6.QtCore \
154168
--hidden-import PyQt6.QtGui \
155169
--hidden-import PyQt6.QtWidgets \
156-
--collect-all PyQt6 \
170+
--exclude-module matplotlib \
171+
--exclude-module numpy \
172+
--exclude-module PIL \
173+
--exclude-module pandas \
174+
--exclude-module scipy \
175+
--exclude-module tkinter \
176+
--exclude-module PyQt6.QtSvg \
177+
--exclude-module PyQt6.QtNetwork \
178+
--exclude-module PyQt6.QtPrintSupport \
157179
main.py
158-
159-
# Apple Silicon Mac 构建
160-
echo "Building for Apple Silicon Mac..."
161-
ARCH="arm64" pyinstaller --noconsole \
180+
181+
- name: Build (Linux)
182+
if: runner.os == 'Linux'
183+
run: |
184+
# 确保文件存在
185+
echo "Checking files..."
186+
ls -la .env
187+
ls -la assets
188+
# 构建
189+
pyinstaller --noconsole \
162190
--add-data ".env:." \
163191
--add-data "assets/*:assets" \
164-
--icon "assets/icon.icns" \
165-
--name "Text2Voice-ARM" \
166-
--add-binary "${ARM_QT_PATH}/lib:Qt6" \
167-
--add-binary "${ARM_QT_PATH}/plugins:Qt6/plugins" \
192+
--icon "assets/icon.png" \
193+
--name "Text2Voice" \
168194
--hidden-import PyQt6.QtCore \
169195
--hidden-import PyQt6.QtGui \
170196
--hidden-import PyQt6.QtWidgets \
171-
--collect-all PyQt6 \
197+
--exclude-module matplotlib \
198+
--exclude-module numpy \
199+
--exclude-module PIL \
200+
--exclude-module pandas \
201+
--exclude-module scipy \
202+
--exclude-module tkinter \
203+
--exclude-module PyQt6.QtSvg \
204+
--exclude-module PyQt6.QtNetwork \
205+
--exclude-module PyQt6.QtPrintSupport \
172206
main.py
173-
174-
# 创建通用二进制(Universal Binary)
175-
echo "Creating Universal Binary..."
176-
mkdir -p "dist/Text2Voice.app/Contents/MacOS"
177-
lipo "dist/Text2Voice-Intel.app/Contents/MacOS/Text2Voice-Intel" \
178-
"dist/Text2Voice-ARM.app/Contents/MacOS/Text2Voice-ARM" \
179-
-create -output "dist/Text2Voice.app/Contents/MacOS/Text2Voice"
180-
181-
# 复制资源文件
182-
cp -R "dist/Text2Voice-Intel.app/Contents/Resources" "dist/Text2Voice.app/Contents/"
183-
cp -R "dist/Text2Voice-Intel.app/Contents/Info.plist" "dist/Text2Voice.app/Contents/"
184-
207+
185208
- name: Create DMG (macOS)
186209
if: runner.os == 'macOS'
187210
run: |

0 commit comments

Comments
 (0)