Files
Shortcut_Sync_PotPlayer/.github/workflows/build-exe.yml

63 lines
2.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Build Windows EXE with Full Image
on: [push]
jobs:
build:
runs-on: Ubuntu_docker_act
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: |
# 升级 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 "${{ env.PYTHON_EXE }}" -m PyInstaller --onefile --windowed --name Shortcut_Sync_PotPlayer main.py
# 步骤6上传构建产物
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: Shortcut_Sync_PotPlayer
path: dist/Shortcut_Sync_PotPlayer.exe