更新 Windows 构建工作流,优化环境变量配置,支持动态 Python 版本和 EXE 名称
Some checks failed
Build Windows EXE with Wine (Universal Template) / build (push) Failing after 6m12s
Some checks failed
Build Windows EXE with Wine (Universal Template) / build (push) Failing after 6m12s
This commit is contained in:
42
.github/workflows/windows-build.yml
vendored
42
.github/workflows/windows-build.yml
vendored
@@ -1,4 +1,4 @@
|
|||||||
name: Build Windows EXE with Wine
|
name: Build Windows EXE with Wine (Universal Template)
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
@@ -9,8 +9,18 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
# 设定全局环境变量,这些变量在所有 steps 中都生效
|
# === 用户配置区:新项目只需修改这里 ===
|
||||||
env:
|
env:
|
||||||
|
# 项目主入口文件
|
||||||
|
MAIN_SCRIPT: dir_scanner_gui.py
|
||||||
|
# 生成的 EXE 文件名称 (不带 .exe 后缀)
|
||||||
|
EXE_NAME: dir_scanner
|
||||||
|
# 依赖配置文件路径 (通常为 requirements.txt)
|
||||||
|
REQUIREMENTS_FILE: requirements.txt
|
||||||
|
# Python 版本号
|
||||||
|
PYTHON_VERSION: 3.9.1
|
||||||
|
|
||||||
|
# === 系统环境变量 (通常无需修改) ===
|
||||||
WINEARCH: win64
|
WINEARCH: win64
|
||||||
WINEPREFIX: /root/.wine
|
WINEPREFIX: /root/.wine
|
||||||
WINEDEBUG: -all # 屏蔽无用的警告日志 (如 missing Gecko)
|
WINEDEBUG: -all # 屏蔽无用的警告日志 (如 missing Gecko)
|
||||||
@@ -36,9 +46,9 @@ jobs:
|
|||||||
sleep 3 # 给虚拟显示器几秒钟的启动时间
|
sleep 3 # 给虚拟显示器几秒钟的启动时间
|
||||||
|
|
||||||
# 步骤 3: 下载 Python Windows 安装包
|
# 步骤 3: 下载 Python Windows 安装包
|
||||||
- name: Download Python 3.9.1
|
- name: Download Python Installer
|
||||||
run: |
|
run: |
|
||||||
wget https://mirrors.tuna.tsinghua.edu.cn/python/3.9.1/python-3.9.1-amd64.exe -O python-installer.exe
|
wget https://mirrors.tuna.tsinghua.edu.cn/python/${{ env.PYTHON_VERSION }}/python-${{ env.PYTHON_VERSION }}-amd64.exe -O python-installer.exe
|
||||||
ls -lh python-installer.exe
|
ls -lh python-installer.exe
|
||||||
|
|
||||||
# 步骤 4: 初始化 Wine 环境
|
# 步骤 4: 初始化 Wine 环境
|
||||||
@@ -75,34 +85,44 @@ jobs:
|
|||||||
echo "Found Python at: $PYTHON_PATH"
|
echo "Found Python at: $PYTHON_PATH"
|
||||||
wine "$PYTHON_PATH" --version
|
wine "$PYTHON_PATH" --version
|
||||||
|
|
||||||
# 步骤 7: 安装 Python 依赖 (增加了 PyQt6)
|
# 步骤 7: 安装 Python 依赖
|
||||||
- name: Install Pip Dependencies
|
- name: Install Pip Dependencies
|
||||||
run: |
|
run: |
|
||||||
# 使用清华源加速
|
# 使用清华源加速升级 pip
|
||||||
wine "$PYTHON_EXE" -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
|
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 PyQt6 -i https://pypi.tuna.tsinghua.edu.cn/simple
|
|
||||||
|
# 必须安装 pyinstaller 用于后续打包操作
|
||||||
|
wine "$PYTHON_EXE" -m pip install pyinstaller -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
|
||||||
|
# 检查并安装 requirements.txt 中的依赖
|
||||||
|
if [ -f "${{ env.REQUIREMENTS_FILE }}" ]; then
|
||||||
|
echo "Installing dependencies from ${{ env.REQUIREMENTS_FILE }}"
|
||||||
|
wine "$PYTHON_EXE" -m pip install -r "${{ env.REQUIREMENTS_FILE }}" -i https://pypi.tuna.tsinghua.edu.cn/simple
|
||||||
|
else
|
||||||
|
echo "Warning: ${{ env.REQUIREMENTS_FILE }} not found, skipping..."
|
||||||
|
fi
|
||||||
wineserver -w
|
wineserver -w
|
||||||
|
|
||||||
# 步骤 8: 执行 PyInstaller 构建
|
# 步骤 8: 执行 PyInstaller 构建
|
||||||
- name: Build EXE
|
- name: Build EXE
|
||||||
run: |
|
run: |
|
||||||
# --clean 参数可以在构建前清理临时文件
|
# --clean 参数可以在构建前清理临时文件
|
||||||
wine "$PYTHON_EXE" -m PyInstaller --onefile --windowed --clean --name Shortcut_Sync_PotPlayer main.py
|
wine "$PYTHON_EXE" -m PyInstaller --onefile --windowed --clean --name "${{ env.EXE_NAME }}" "${{ env.MAIN_SCRIPT }}"
|
||||||
wineserver -w
|
wineserver -w
|
||||||
|
|
||||||
# 步骤 9: 上传 Artifact (Gitea 专用版本)
|
# 步骤 9: 上传 Artifact (Gitea 专用版本)
|
||||||
- name: Upload Artifact
|
- name: Upload Artifact
|
||||||
uses: christopherhx/gitea-upload-artifact@v4
|
uses: christopherhx/gitea-upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: Shortcut_Sync_PotPlayer
|
name: ${{ env.EXE_NAME }}
|
||||||
path: dist/Shortcut_Sync_PotPlayer.exe
|
path: dist/${{ env.EXE_NAME }}.exe
|
||||||
|
|
||||||
# 步骤 10: 发布 Release (仅在推送 tag 时执行)
|
# 步骤 10: 发布 Release (仅在推送 tag 时执行)
|
||||||
- name: Create Release
|
- name: Create Release
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
uses: https://gitea.com/actions/release-action@main
|
uses: https://gitea.com/actions/release-action@main
|
||||||
with:
|
with:
|
||||||
files: dist/Shortcut_Sync_PotPlayer.exe
|
files: dist/${{ env.EXE_NAME }}.exe
|
||||||
api_key: '${{ secrets.GITHUB_TOKEN }}'
|
api_key: '${{ secrets.GITHUB_TOKEN }}'
|
||||||
name: 'Release ${{ github.ref_name }}'
|
name: 'Release ${{ github.ref_name }}'
|
||||||
draft: false
|
draft: false
|
||||||
|
|||||||
Reference in New Issue
Block a user