@@ -19,124 +19,82 @@ jobs:
1919 name : Build on ${{ matrix.os }}
2020 runs-on : ${{ matrix.os }}
2121 strategy :
22- fail-fast : false # 一个平台失败不影响其他平台
22+ fail-fast : false
2323 matrix :
24- os : [windows-latest, macos-latest]
25- python-version : ['3.12'] # 更新到 Python 3.12
24+ include :
25+ - os : macos-14 # macos-14 是 M1/M2 runner
26+ arch : arm64
27+ python-version : ' 3.12'
28+ - os : windows-latest
29+ arch : x64
30+ python-version : ' 3.12'
2631
2732 steps :
2833 - name : Checkout code
2934 uses : actions/checkout@v4
3035 with :
31- fetch-depth : 0 # 获取完整的历史记录用于版本信息
36+ fetch-depth : 0
3237
3338 - name : Set up Python
3439 uses : actions/setup-python@v5
3540 with :
3641 python-version : ${{ matrix.python-version }}
37- architecture : ' x64 '
42+ architecture : ${{ matrix.arch }}
3843 cache : ' pip'
39- check-latest : true # 确保使用最新的补丁版本
44+ check-latest : true
4045
4146 - name : Verify Python installation
4247 run : |
4348 python --version
44- which python
49+ which python || where python
4550 python -c "import sys; print(sys.prefix)"
4651 python -m pip --version
4752
4853 # 创建必要的文件和目录
49- - name : Create necessary files and directories
54+ - name : Create necessary files
5055 shell : bash
5156 run : |
52- # 创建 .env 文件
53- if [ ! -f ".env" ]; then
54- echo "Creating .env file..."
55- echo "SILICON_API_KEY=dummy_key" > .env
56- fi
57-
58- # 创建必要目录
59- for dir in "assets" "temp" "logs" "resources"; do
60- if [ ! -d "$dir" ]; then
61- echo "Creating $dir directory..."
62- mkdir -p "$dir"
63- fi
64- done
57+ # 创建必要目录和文件
58+ mkdir -p resources assets temp logs
59+ touch resources/placeholder.txt assets/placeholder.txt
60+ echo "SILICON_API_KEY=dummy_key" > .env
6561
66- # 显示目录结构
6762 echo "Directory structure:"
6863 ls -la
69-
64+
7065 - name : Install dependencies
7166 run : |
72- python -m pip install --upgrade pip
67+ python -m pip install --upgrade pip setuptools wheel
7368 pip install -r requirements.txt
7469 pip install pyinstaller
7570
76- # macOS 特定配置
77- - name : Install macOS dependencies
71+ # macOS M1/M2 特定配置
72+ - name : Install macOS ARM dependencies
7873 if : runner.os == 'macOS'
7974 run : |
75+ # Homebrew 在 M1/M2 Mac 上的路径是固定的
76+ BREW_PREFIX="/opt/homebrew"
77+ echo "Using Homebrew at: $BREW_PREFIX"
78+
8079 # 安装系统依赖
81- brew install gettext
82- brew link gettext --force
8380 brew install qt6
8481
85- # 验证 gettext 安装
86- echo "Checking gettext installation..."
87- ls -l /usr/local/opt/gettext/lib/
88- otool -L /usr/local/opt/gettext/lib/libintl*.dylib
89-
9082 # 设置环境变量
91- echo "Setting up environment variables..."
92- echo "LDFLAGS=-L/usr/local/opt/gettext/lib" >> $GITHUB_ENV
93- echo "CPPFLAGS=-I/usr/local/opt/gettext/include" >> $GITHUB_ENV
94-
95- # 安装 Python 依赖
96- echo "Installing Python dependencies..."
97- python -m pip install --upgrade pip setuptools wheel
98-
99- # 安装 PyQt6
100- python -m pip install PyQt6>=6.4.2
101- python -m pip install PyQt6-Qt6>=6.4.2
102- python -m pip install PyQt6-sip>=13.4.1
83+ echo "PYTHONPATH=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
84+ echo "QT_PLUGIN_PATH=$BREW_PREFIX/opt/qt6/plugins" >> $GITHUB_ENV
85+ echo "QT_DEBUG_PLUGINS=1" >> $GITHUB_ENV
10386
104- # 安装 pygame
105- python -m pip install pygame>=2.5.2
87+ # 显示 Qt 安装信息
88+ brew list qt6 --verbose
10689
10790 echo "Installed packages:"
10891 pip list
10992
110- - name : Set macOS environment
111- if : runner.os == 'macOS'
112- run : |
113- echo "QT_DEBUG_PLUGINS=1" >> $GITHUB_ENV
114- echo "PYTHONPATH=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
115- echo "DYLD_LIBRARY_PATH=/usr/local/opt/gettext/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
116-
11793 # Windows 构建
11894 - name : Build (Windows)
11995 if : runner.os == 'Windows'
12096 shell : cmd
12197 run : |
122- # 检查目录结构
123- dir
124-
125- # 确保必要目录存在
126- if not exist "resources" mkdir resources
127- if not exist "assets" mkdir assets
128- if not exist "temp" mkdir temp
129- if not exist "logs" mkdir logs
130-
131- # 创建一个空的资源文件,确保目录不为空
132- echo. > resources\placeholder.txt
133- echo. > assets\placeholder.txt
134-
135- # 显示目录结构
136- echo "Directory structure after creation:"
137- dir /s
138-
139- # 执行构建
14098 pyinstaller ^
14199 --noconsole ^
142100 --add-data ".env;." ^
@@ -153,31 +111,16 @@ jobs:
153111 --hidden-import pygame ^
154112 main.py
155113
156- # macOS 构建
157- - name : Build (macOS)
114+ # macOS ARM 构建
115+ - name : Build (macOS ARM )
158116 if : runner.os == 'macOS'
159117 run : |
160- # 检查目录结构
161- ls -la
162-
163- # 确保必要目录存在
164- mkdir -p resources assets temp logs
165-
166- # 创建占位文件
167- touch resources/placeholder.txt
168- touch assets/placeholder.txt
169-
170- # 显示目录结构
171- echo "Directory structure after creation:"
172- find . -type d
173-
174- # 执行构建
175118 pyinstaller --noconsole \
176119 --add-data ".env:." \
177120 --add-data "assets:assets" \
178121 --add-data "resources:resources" \
179122 --add-data "ui/styles:ui/styles" \
180- --name "Text2Voice-Intel " \
123+ --name "Text2Voice-ARM " \
181124 --hidden-import PyQt6.QtCore \
182125 --hidden-import PyQt6.QtGui \
183126 --hidden-import PyQt6.QtWidgets \
@@ -187,56 +130,44 @@ jobs:
187130 --hidden-import pygame \
188131 main.py
189132
190- # 创建 DMG (macOS)
191- - name : Create DMG (macOS)
133+ # 创建 DMG (macOS ARM )
134+ - name : Create DMG (macOS ARM )
192135 if : runner.os == 'macOS'
193136 run : |
194- brew install create-dmg || exit 1
137+ brew install create-dmg
138+ chmod +x "dist/Text2Voice-ARM.app/Contents/MacOS/Text2Voice-ARM"
195139
196- # 确保执行权限
197- chmod +x "dist/Text2Voice-Intel.app/Contents/MacOS/Text2Voice-Intel"
198-
199- # 添加错误处理
200- if ! create-dmg \
140+ create-dmg \
201141 --volname "Text2Voice" \
202142 --window-pos 200 120 \
203143 --window-size 800 400 \
204144 --icon-size 100 \
205- --icon "Text2Voice-Intel .app" 200 190 \
206- --hide-extension "Text2Voice-Intel .app" \
145+ --icon "Text2Voice-ARM .app" 200 190 \
146+ --hide-extension "Text2Voice-ARM .app" \
207147 --app-drop-link 600 185 \
208- "Text2Voice-Intel.dmg" \
209- "dist/"; then
210- echo "DMG creation failed"
211- exit 1
212- fi
148+ "Text2Voice-ARM.dmg" \
149+ "dist/" || exit 1
213150
214151 # 打包制品
215152 - name : Zip Artifacts
216153 shell : bash
217154 run : |
218- echo "Creating zip archives..."
219155 cd dist || exit 1
220-
221156 if [ "${{ runner.os }}" == "Windows" ]; then
222157 7z a ../Text2Voice-windows-latest.zip ./* || exit 1
223- echo "Windows zip created successfully"
224158 elif [ "${{ runner.os }}" == "macOS" ]; then
225- zip -r ../Text2Voice-macos-intel-latest.zip ./* || exit 1
226- echo "macOS zip created successfully"
159+ zip -r ../Text2Voice-macos-arm-latest.zip ./* || exit 1
227160 fi
228-
229161 cd ..
230162
231- # 显示创建的文件
232163 echo "Created files:"
233164 ls -lh Text2Voice-*.zip Text2Voice-*.dmg 2>/dev/null || true
234165
235166 # 上传制品
236167 - name : Upload Artifacts
237168 uses : actions/upload-artifact@v4
238169 with :
239- name : Text2Voice-${{ runner .os }}
170+ name : Text2Voice-${{ matrix .os }}-${{ matrix.arch }}
240171 path : |
241172 Text2Voice-*.zip
242173 Text2Voice-*.dmg
@@ -256,22 +187,16 @@ jobs:
256187 - 版本: ${{ github.ref_name }}
257188 - 时间: ${{ github.event.head_commit.timestamp }}
258189 - 提交: ${{ github.event.head_commit.message }}
259- - 分支: ${{ github.ref_name }}
260190
261191 ### 下载
262192 - Windows 版本: Text2Voice-windows-latest.zip
263- - macOS Intel 版本: Text2Voice-macos-intel-latest.zip
264- - DMG 安装包: Text2Voice-Intel.dmg
265-
266- ### 更新说明
267- {{ 请在此处添加版本更新说明 }}
193+ - macOS ARM (M1/M2) 版本: Text2Voice-macos-arm-latest.zip
194+ - macOS ARM DMG: Text2Voice-ARM.dmg
268195
269196 files : |
270197 Text2Voice-windows-latest.zip
271- Text2Voice-macos-intel-latest.zip
272- Text2Voice-*.dmg
273- draft : false
274- prerelease : false
198+ Text2Voice-macos-arm-latest.zip
199+ Text2Voice-ARM.dmg
275200 env :
276201 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
277202
0 commit comments