更新 .github/workflows/build-exe.yml
Some checks failed
Build Windows EXE with Wine / build (push) Failing after 3m0s
Some checks failed
Build Windows EXE with Wine / build (push) Failing after 3m0s
This commit is contained in:
56
.github/workflows/build-exe.yml
vendored
56
.github/workflows/build-exe.yml
vendored
@@ -8,12 +8,19 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# 设定全局环境变量,这些变量在所有 steps 中都生效
|
||||
env:
|
||||
WINEARCH: win64
|
||||
WINEPREFIX: /root/.wine
|
||||
WINEDEBUG: -all # 屏蔽无用的警告日志 (如 missing Gecko)
|
||||
DISPLAY: :99 # 统一使用 99 号虚拟显示器
|
||||
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# 步骤 1: 安装必要依赖 (Wine 和 Xvfb)
|
||||
# 增加 i386 架构支持以解决某些安装程序无法运行的问题
|
||||
# 步骤 1: 安装必要依赖
|
||||
- name: Install System Dependencies
|
||||
run: |
|
||||
sudo dpkg --add-architecture i386
|
||||
@@ -21,35 +28,42 @@ jobs:
|
||||
sudo apt-get install -y xvfb wine64 wine32 wine binutils
|
||||
sudo apt-get clean # 及时清理 apt 缓存节省硬盘空间
|
||||
|
||||
# 步骤 2: 下载 Python Windows 安装包
|
||||
# 步骤 2: 在后台持续运行 Xvfb
|
||||
- name: Start Xvfb
|
||||
run: |
|
||||
# 启动 X 虚拟屏幕并放到后台,供整个工作流期间的 Wine 使用
|
||||
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
|
||||
sleep 3 # 给虚拟显示器几秒钟的启动时间
|
||||
|
||||
# 步骤 3: 下载 Python Windows 安装包
|
||||
- name: Download Python 3.9.9
|
||||
run: |
|
||||
wget https://mirrors.tuna.tsinghua.edu.cn/python/3.9.9/python-3.9.9-amd64.exe -O python-installer.exe
|
||||
ls -lh python-installer.exe
|
||||
|
||||
# 步骤 3: 初始化 Wine 环境
|
||||
# 步骤 4: 初始化 Wine 环境
|
||||
- name: Setup Wine Environment
|
||||
run: |
|
||||
export WINEARCH=win64
|
||||
export WINEPREFIX=$HOME/.wine
|
||||
# 使用 xvfb-run 启动,避免 GUI 错误
|
||||
xvfb-run --auto-servernum wineboot -u
|
||||
sleep 5
|
||||
# 初始化 Wine,不再使用 xvfb-run
|
||||
wineboot -u
|
||||
# 重要:等待 Wine 后台配置进程完全结束
|
||||
wineserver -w
|
||||
|
||||
# 步骤 4: 在 Wine 中安装 Python
|
||||
# 步骤 5: 在 Wine 中安装 Python
|
||||
- name: Install Python in Wine
|
||||
run: |
|
||||
# /quiet 表示静默安装,这是在 CI 环境中运行的关键
|
||||
xvfb-run --auto-servernum wine python-installer.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
|
||||
sleep 15
|
||||
# /quiet 表示静默安装
|
||||
wine python-installer.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
|
||||
# 重要:静默安装往往是异步的,必须等待 wineserver 彻底结束,防止 X connection 突然断开
|
||||
wineserver -w
|
||||
# 安装完后立即删除安装包,释放硬盘
|
||||
rm python-installer.exe
|
||||
|
||||
# 步骤 5: 验证并定位 Python 路径
|
||||
# 步骤 6: 验证并定位 Python 路径
|
||||
- name: Verify Python Path
|
||||
run: |
|
||||
# 动态查找 python.exe 路径并存入环境变量
|
||||
PYTHON_PATH=$(find $HOME/.wine/drive_c -name "python.exe" | head -n 1)
|
||||
PYTHON_PATH=$(find $WINEPREFIX/drive_c -name "python.exe" | head -n 1)
|
||||
if [ -z "$PYTHON_PATH" ]; then
|
||||
echo "Python installation failed!"
|
||||
exit 1
|
||||
@@ -58,27 +72,29 @@ jobs:
|
||||
echo "Found Python at: $PYTHON_PATH"
|
||||
wine "$PYTHON_PATH" --version
|
||||
|
||||
# 步骤 6: 安装 Python 依赖
|
||||
# 步骤 7: 安装 Python 依赖
|
||||
- name: Install Pip Dependencies
|
||||
run: |
|
||||
# 使用清华源加速并节省网络开销
|
||||
# 使用清华源加速
|
||||
wine "$PYTHON_EXE" -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
wine "$PYTHON_EXE" -m pip install pyinstaller keyboard pywin32 -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||
wineserver -w
|
||||
|
||||
# 步骤 7: 执行 PyInstaller 构建
|
||||
# 步骤 8: 执行 PyInstaller 构建
|
||||
- name: Build EXE
|
||||
run: |
|
||||
# --clean 参数可以在构建前清理临时文件
|
||||
wine "$PYTHON_EXE" -m PyInstaller --onefile --windowed --clean --name Shortcut_Sync_PotPlayer main.py
|
||||
wineserver -w
|
||||
|
||||
# 步骤 8: 上传 Artifact (Gitea 专用版本)
|
||||
# 步骤 9: 上传 Artifact (Gitea 专用版本)
|
||||
- name: Upload Artifact
|
||||
uses: christopherhx/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: Shortcut_Sync_PotPlayer
|
||||
path: dist/Shortcut_Sync_PotPlayer.exe
|
||||
|
||||
# 步骤 9: 发布 Release (仅在推送 tag 时执行)
|
||||
# 步骤 10: 发布 Release (仅在推送 tag 时执行)
|
||||
- name: Create Release
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: https://gitea.com/actions/release-action@main
|
||||
|
||||
Reference in New Issue
Block a user