@@ -30,71 +30,48 @@ jobs:
3030 echo "next_version=$next_version" >> $GITHUB_OUTPUT
3131 echo "将创建新版本: $next_version"
3232
33- build-and-release :
33+ build-windows :
3434 needs : get-next-version
35- runs-on : ${{ matrix.os }}
36- strategy :
37- fail-fast : false
38- matrix :
39- os : [ubuntu-latest, windows-latest]
40- python-version : ["3.8"] # 关键:使用 Python 3.8(Win7 最后支持的版本)
41-
35+ runs-on : windows-latest # 直接指定 Windows 环境,不使用 matrix
4236 steps :
4337 - uses : actions/checkout@v4
4438
45- - name : Set up Python 3.8
39+ - name : Set up Python 3.8 (Win7 兼容)
4640 uses : actions/setup-python@v5
4741 with :
48- python-version : ${{ matrix.python-version }}
49- # 可选:指定缓存依赖路径(加速构建)
50- cache : ' pip'
42+ python-version : " 3.8" # 直接指定 Python 版本
5143
52- - name : Install compatible PyInstaller (Win7 support)
44+ - name : Install dependencies
5345 run : |
5446 python -m pip install --upgrade pip
55- # PyInstaller 5.13 是最后支持 Python 3.8 且兼容 Win7 的版本之一
56- pip install pyinstaller==5.13
57- if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
58- shell : ${{ contains(matrix.os, 'windows') && 'pwsh' || 'bash' }}
59-
60- - name : Set OS name env
61- run : |
62- if [[ "${{ matrix.os }}" == *"windows"* ]]; then
63- echo "OS_NAME=windows" >> $GITHUB_ENV
64- else
65- echo "OS_NAME=linux" >> $GITHUB_ENV
66- fi
67- shell : bash
47+ pip install pyinstaller==5.13 # 兼容 Win7 的版本
48+ if (Test-Path "requirements.txt") { pip install -r requirements.txt }
49+ shell : pwsh # 直接使用 PowerShell(Windows 环境)
6850
69- - name : Package with pyinstaller (Win7 compatible )
51+ - name : Package with pyinstaller (Win7 兼容 )
7052 run : |
71- # 针对 Windows 7 额外添加兼容性参数
72- if [ "$env:OS_NAME" = "windows" ]; then
73- pyinstaller --onefile --name "myapp-${{ needs.get-next-version.outputs.next_version }}-$env:OS_NAME" \
74- --win-private-assemblies \ # 打包私有依赖,避免系统依赖冲突
75- main.py
76- else
77- pyinstaller --onefile --name "myapp-${{ needs.get-next-version.outputs.next_version }}-$env:OS_NAME" \
78- main.py
79- fi
80- shell : ${{ contains(matrix.os, 'windows') && 'pwsh' || 'bash' }}
53+ $nextVersion = "${{ needs.get-next-version.outputs.next_version }}"
54+ pyinstaller --onefile --name "myapp-$nextVersion-windows" --win-private-assemblies main.py
55+ shell : pwsh
8156
82- - name : Upload artifacts
57+ - name : Upload Windows artifact
8358 uses : actions/upload-artifact@v4
8459 with :
85- name : myapp-${{ needs.get-next-version.outputs.next_version }}-${{ matrix.os }}
60+ name : myapp-${{ needs.get-next-version.outputs.next_version }}-windows
8661 path : dist/
8762
8863 create-tag-and-release :
89- needs : [get-next-version, build-and-release ]
64+ needs : [get-next-version, build-windows ]
9065 runs-on : ubuntu-latest
9166 steps :
9267 - uses : actions/checkout@v4
9368 with :
9469 fetch-depth : 0
9570
96- - name : Download all artifacts
71+ - name : Download Windows artifact
9772 uses : actions/download-artifact@v4
73+ with :
74+ name : myapp-${{ needs.get-next-version.outputs.next_version }}-windows
9875
9976 - name : Create Git tag
10077 run : |
11289 name : Release ${{ needs.get-next-version.outputs.next_version }} (Win7 兼容)
11390 body : |
11491 自动发布版本 ${{ needs.get-next-version.outputs.next_version }}
115- 支持 Windows 7(基于 Python 3.8)和 Linux 系统
116- files : |
117- myapp-${{ needs.get-next-version.outputs.next_version }}-ubuntu-latest/*
118- myapp-${{ needs.get-next-version.outputs.next_version }}-windows-latest/*
92+ 仅包含 Windows 版本(支持 Windows 7)
93+ files : myapp-${{ needs.get-next-version.outputs.next_version }}-windows/*
11994 env :
12095 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments