diff --git a/.github/workflows/build-exe.yml b/.github/workflows/build-exe.yml index 75b0e82..4a8aab8 100644 --- a/.github/workflows/build-exe.yml +++ b/.github/workflows/build-exe.yml @@ -7,15 +7,55 @@ jobs: steps: - uses: actions/checkout@v4 + # 步骤1:下载你指定的 Python 安装包 + - name: Download Python 3.9.13 installer + run: | + wget https://www.python.org/ftp/python/3.9.13/python-3.9.13-amd64.exe + ls -lh python-3.9.13-amd64.exe # 确认文件下载成功 + + # 步骤2:使用 Xvfb 在 Wine 中静默安装 Python + - name: Install Python in Wine + run: | + # 使用 xvfb-run 包装 wine 以解决无显示问题 + # /quiet: 静默安装,InstallAllUsers=1: 为所有用户安装,PrependPath=1: 自动添加到 PATH + # Include_test=0: 不安装测试套件,以节省空间 + xvfb-run wine python-3.9.13-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0 + echo "Python installation initiated. Waiting for process to complete..." + # 等待几秒确保安装完成 + sleep 10 + + # 步骤3:验证 Python 是否正确安装(关键步骤!) + - name: Verify Python installation + run: | + echo "=== Searching for python.exe ===" + # 查找刚安装的 Python,这能帮你确认确切的路径 + PYTHON_EXE_PATH=$(find /root/.wine/drive_c -name "python.exe" -path "*/Python39/*" | head -n 1) + if [ -z "$PYTHON_EXE_PATH" ]; then + echo "Python.exe not found! Installation may have failed." + exit 1 + fi + echo "Found Python at: $PYTHON_EXE_PATH" + echo "PYTHON_EXE=$PYTHON_EXE_PATH" >> $GITHUB_ENV # 保存路径供后续步骤使用 + + echo "=== Verifying Python version ===" + # 使用完整路径调用 Python 验证 + wine "$PYTHON_EXE_PATH" --version + + # 步骤4:使用刚安装的 Python 安装依赖 - name: Install dependencies run: | - wine-xvfb python -m pip install --upgrade pip - wine-xvfb python -m pip install pyinstaller keyboard pywin32 - + # 升级 pip + wine "${{ env.PYTHON_EXE }}" -m pip install --upgrade pip + # 安装所需包。pywin32 必须在这里用 Wine 的 Python 安装 + wine "${{ env.PYTHON_EXE }}" -m pip install pyinstaller keyboard pywin32 + + # 步骤5:使用正确的 Python 和 PyInstaller 构建 EXE - name: Build EXE run: | - wine-xvfb python -m PyInstaller --onefile --windowed --name Shortcut_Sync_PotPlayer main.py - + # 确保在工作目录执行 + wine "${{ env.PYTHON_EXE }}" -m PyInstaller --onefile --windowed --name Shortcut_Sync_PotPlayer main.py + + # 步骤6:上传构建产物 - name: Upload Artifact uses: actions/upload-artifact@v4 with: