1212 fail-fast : false
1313 matrix :
1414 include :
15+ # ----- Native Builds -----
1516 # ===== Linux =====
1617 - os : linux
1718 arch : x86_64
4647 py_arch : arm64
4748 desc : macos-arm64
4849
50+ # ----- Emulated Builds (都运行在 ubuntu-22.04 x86_64 上) -----
51+ - os : linux
52+ arch : x86
53+ runs_on : ubuntu-22.04
54+ desc : linux-x86
55+ image : i386/debian:12 # 使用 Debian 12 作为替代
56+ - os : linux
57+ arch : armv7
58+ runs_on : ubuntu-22.04
59+ desc : linux-armv7
60+ image : arm32v7/ubuntu:22.04
61+
4962 runs-on : ${{ matrix.runs_on }}
5063
5164 permissions :
@@ -57,27 +70,61 @@ jobs:
5770 with :
5871 fetch-depth : 0
5972
60- # 安装对应架构的 Python
61- - name : Set up Python
73+ # ===================================================================
74+ # 分支 1: Native Builds (x86_64, arm64, windows, macos)
75+ # ===================================================================
76+ - name : Set up Python (Native)
77+ if : " !matrix.image" # 只在没有定义 matrix.image 的原生构建上运行
6278 uses : actions/setup-python@v5
6379 with :
6480 python-version : ' 3.12'
6581 architecture : ${{ matrix.py_arch }}
6682
67- - name : Install dependencies
83+ - name : Install dependencies (Native)
84+ if : " !matrix.image"
6885 run : |
6986 python -m pip install --upgrade pip
7087 if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
7188 pip install pyinstaller
7289 shell : bash
7390
74- - name : Build with PyInstaller
91+ - name : Build with PyInstaller (Native)
92+ if : " !matrix.image"
7593 run : |
7694 mkdir -p dist
7795 pyinstaller --onefile --name TJUEcardSetup setup.py
7896 pyinstaller --onefile --noconsole --name TJUEcard TJUEcard_main.py
7997 shell : bash
8098
99+ # ===================================================================
100+ # 分支 2: Emulated Builds (x86, armv7)
101+ # ===================================================================
102+ - name : Set up QEMU
103+ if : " matrix.image" # 只在需要模拟的构建上运行
104+ uses : docker/setup-qemu-action@v3
105+
106+ - name : Build with PyInstaller (Emulated)
107+ if : " matrix.image"
108+ run : |
109+ # 在容器内执行所有安装和构建步骤
110+ docker run --rm --privileged \
111+ -v "${{ github.workspace }}":/workspace \
112+ -w /workspace \
113+ ${{ matrix.image }} \
114+ sh -c " \
115+ set -ex; \
116+ apt-get update; \
117+ apt-get install -y python3 python3-pip git; \
118+ ln -s /usr/bin/python3 /usr/bin/python || true; \
119+ python -m pip install --upgrade pip; \
120+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi; \
121+ pip install pyinstaller; \
122+ pyinstaller --onefile --name TJUEcardSetup setup.py; \
123+ pyinstaller --onefile --noconsole --name TJUEcard TJUEcard_main.py \
124+ "
125+
126+ # ============ 从这里开始,所有分支的步骤合并 ============
127+
81128 # ===== 验证架构 =====
82129 - name : Check binary arch (Linux)
83130 if : runner.os == 'Linux'
0 commit comments