@@ -24,31 +24,64 @@ jobs:
2424 exe_ext : .exe
2525 archive_format : zip
2626 archive_ext : .zip
27+ target : desktop
28+ artifact_suffix : " "
29+ enable_gui : true
30+
2731 - os : macos-15-intel
2832 goos : darwin
2933 goarch : amd64
30- exe_ext : ' '
34+ exe_ext : " "
3135 archive_format : zip
3236 archive_ext : .zip
37+ target : desktop
38+ artifact_suffix : " "
39+ enable_gui : true
40+
3341 - os : macos-14
3442 goos : darwin
3543 goarch : arm64
36- exe_ext : ' '
44+ exe_ext : " "
3745 archive_format : zip
3846 archive_ext : .zip
47+ target : desktop
48+ artifact_suffix : " "
49+ enable_gui : true
50+
51+ # Linux 桌面版(原来的)
3952 - os : ubuntu-latest
4053 goos : linux
4154 goarch : amd64
42- exe_ext : ' '
55+ exe_ext : " "
4356 archive_format : tar.gz
4457 archive_ext : .tar.gz
45-
58+ target : desktop
59+ artifact_suffix : " "
60+ enable_gui : true
61+ cgo_enabled : " 1"
62+
4663 - os : ubuntu-24.04-arm
4764 goos : linux
4865 goarch : arm64
49- exe_ext : ' '
66+ exe_ext : " "
67+ archive_format : tar.gz
68+ archive_ext : .tar.gz
69+ target : desktop
70+ artifact_suffix : " "
71+ enable_gui : true
72+ cgo_enabled : " 1"
73+
74+ # ✅ 新增:Linux amd64 软路由版(OpenWrt / iStoreOS 等)
75+ - os : ubuntu-latest
76+ goos : linux
77+ goarch : amd64
78+ exe_ext : " "
5079 archive_format : tar.gz
5180 archive_ext : .tar.gz
81+ target : softrouter
82+ artifact_suffix : " -softrouter"
83+ enable_gui : false # 路由器上一般不跑 GUI
84+ cgo_enabled : " 0" # 尽量静态,方便在各种 musl 系统上跑
5285
5386 runs-on : ${{ matrix.os }}
5487
@@ -68,25 +101,32 @@ jobs:
68101 go mod tidy
69102
70103 - name : Build Go executable
104+ env :
105+ GOOS : ${{ matrix.goos }}
106+ GOARCH : ${{ matrix.goarch }}
107+ CGO_ENABLED : ${{ matrix.cgo_enabled || '1' }}
71108 run : |
72- GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ech-workers${{ matrix.exe_ext }} ech-workers.go
109+ echo "Building for $GOOS/$GOARCH (target=${{ matrix.target }}, CGO_ENABLED=$CGO_ENABLED)"
110+ go build -trimpath -ldflags="-s -w" -o ech-workers${{ matrix.exe_ext }} ech-workers.go
73111 shell : bash
74112
113+ # 下面这几个步骤:只有打 tag + 且当前目标允许 GUI 时才跑
114+
75115 - name : Set up Python
76- if : startsWith(github.ref, 'refs/tags/')
116+ if : startsWith(github.ref, 'refs/tags/') && matrix.enable_gui == true
77117 uses : actions/setup-python@v5
78118 with :
79119 python-version : ' 3.11'
80120
81121 - name : Install system dependencies (Linux)
82- if : startsWith(github.ref, 'refs/tags/') && matrix.goos == 'linux'
122+ if : startsWith(github.ref, 'refs/tags/') && matrix.goos == 'linux' && matrix.enable_gui == true
83123 run : |
84124 sudo apt-get update
85125 sudo apt-get install -y python3-pyqt5 python3-pyqt5.qtsvg python3-dev
86126 shell : bash
87127
88128 - name : Install PyInstaller and dependencies
89- if : startsWith(github.ref, 'refs/tags/')
129+ if : startsWith(github.ref, 'refs/tags/') && matrix.enable_gui == true
90130 run : |
91131 python -m pip install --upgrade pip
92132 if [ "${{ matrix.goos }}" == "linux" ]; then
@@ -101,23 +141,18 @@ jobs:
101141 shell : bash
102142
103143 - name : Build Python executable
104- if : startsWith(github.ref, 'refs/tags/')
144+ if : startsWith(github.ref, 'refs/tags/') && matrix.enable_gui == true
105145 run : |
106- # PyInstaller 会自动使用当前系统架构
107- # macos-13 = Intel (x86_64), macos-14 = Apple Silicon (arm64)
108- # ubuntu-latest = x86_64, ubuntu-latest-arm64 = ARM64
109146 if [ "${{ matrix.goos }}" == "windows" ]; then
110147 pyinstaller --onefile --windowed --name ECHWorkersGUI gui.py
111148 elif [ "${{ matrix.goos }}" == "linux" ]; then
112- # Linux: 检查 PyQt5 是否可用
113149 if python -c "import PyQt5.QtWidgets" 2>/dev/null; then
114150 pyinstaller --onefile --name ECHWorkersGUI gui.py
115151 else
116152 echo "PyQt5 not available, skipping GUI build for Linux"
117153 echo "Only Go executable will be included"
118154 fi
119155 else
120- # macOS 不需要 --windowed(会隐藏控制台)
121156 pyinstaller --onefile --name ECHWorkersGUI gui.py
122157 fi
123158 shell : bash
@@ -130,56 +165,68 @@ jobs:
130165 # 复制 Go 可执行文件
131166 cp ech-workers${{ matrix.exe_ext }} release/
132167
133- # 复制 Python 打包后的可执行文件
134- if [ "${{ matrix.goos }}" == "windows" ]; then
135- if [ -f "dist/ECHWorkersGUI.exe" ]; then
136- cp dist/ECHWorkersGUI.exe release/
137- fi
138- else
139- if [ -f "dist/ECHWorkersGUI" ]; then
140- cp dist/ECHWorkersGUI release/
141- chmod +x release/ECHWorkersGUI
142- elif [ "${{ matrix.goos }}" == "linux" ]; then
143- echo "GUI executable not built, only Go executable will be included"
168+ # 复制 Python 打包后的可执行文件(仅桌面版)
169+ if [ "${{ matrix.enable_gui }}" = "true" ]; then
170+ if [ "${{ matrix.goos }}" == "windows" ]; then
171+ if [ -f "dist/ECHWorkersGUI.exe" ]; then
172+ cp dist/ECHWorkersGUI.exe release/
173+ fi
174+ else
175+ if [ -f "dist/ECHWorkersGUI" ]; then
176+ cp dist/ECHWorkersGUI release/
177+ chmod +x release/ECHWorkersGUI
178+ elif [ "${{ matrix.goos }}" == "linux" ]; then
179+ echo "GUI executable not built, only Go executable will be included"
180+ fi
144181 fi
145182 fi
146183
147184 # 创建 README
148185 {
149186 echo "ECH Workers Client"
150187 echo ""
188+ echo "Target: ${{ matrix.target }}"
189+ echo ""
151190 echo "Files:"
152- echo "- ech-workers(.exe) : Go compiled core proxy program"
153- if [ "${{ matrix.goos }}" == "windows " ]; then
154- echo "- ECHWorkersGUI.exe: Python GUI client (standalone executable)"
155- elif [ "${{ matrix.goos }}" == "linux" ]; then
156- if [ -f "release/ECHWorkersGUI" ]; then
191+ echo "- ech-workers${{ matrix.exe_ext }} : Go compiled core proxy program"
192+ if [ "${{ matrix.enable_gui }}" = "true " ]; then
193+ if [ "${{ matrix.goos }}" == "windows" ]; then
194+ echo "- ECHWorkersGUI.exe: Python GUI client (standalone executable)"
195+ elif [ -f "release/ECHWorkersGUI" ]; then
157196 echo "- ECHWorkersGUI: Python GUI client (standalone executable)"
158197 else
159198 echo "- Note: GUI client not available for this architecture"
160199 echo " Use ech-workers from command line instead"
161200 fi
162201 else
163- echo "- ECHWorkersGUI: Python GUI client (standalone executable )"
202+ echo "- GUI client not included for this build (CLI only, suitable for routers / servers )"
164203 fi
165204 echo ""
166205 echo "Usage:"
167206 if [ "${{ matrix.goos }}" == "windows" ]; then
168- echo "1. Double-click ECHWorkersGUI.exe to launch the GUI"
207+ echo "1. Double-click ECHWorkersGUI.exe to launch the GUI (if present) "
169208 echo "2. Or run ech-workers.exe from command line"
170209 else
171- echo "1. Run ./ECHWorkersGUI to launch the GUI"
172- echo "2. Or run ./ech-workers from command line"
210+ echo "1. Run ./ech-workers from command line"
211+ if [ "${{ matrix.enable_gui }}" = "true" ]; then
212+ echo "2. Or run ./ECHWorkersGUI to launch the GUI"
213+ fi
173214 fi
174215 echo ""
175216 echo "System Requirements:"
176- if [ "${{ matrix.goos }}" == "windows" ]; then
177- echo "- Windows: Windows 10+"
178- elif [ "${{ matrix.goos }}" == "darwin" ]; then
179- echo "- macOS: macOS 10.13+"
180- else
181- echo "- Linux: Ubuntu 18.04+ / Debian 10+ / CentOS 7+"
217+ if [ "${{ matrix.target }}" = "softrouter" ]; then
218+ echo "- Linux soft router / NAS (OpenWrt / iStoreOS / x86_64)"
182219 echo "- Architecture: ${{ matrix.goarch }}"
220+ echo "- Recommended: run from SSH / shell"
221+ else
222+ if [ "${{ matrix.goos }}" == "windows" ]; then
223+ echo "- Windows: Windows 10+"
224+ elif [ "${{ matrix.goos }}" == "darwin" ]; then
225+ echo "- macOS: macOS 10.13+"
226+ else
227+ echo "- Linux: Ubuntu 18.04+ / Debian 10+ / CentOS 7+"
228+ echo "- Architecture: ${{ matrix.goarch }}"
229+ fi
183230 fi
184231 echo "- No Python installation required (standalone executables)"
185232 } > release/README.txt
@@ -189,29 +236,29 @@ jobs:
189236 if : startsWith(github.ref, 'refs/tags/') && matrix.goos == 'windows'
190237 run : |
191238 cd release
192- powershell Compress-Archive -Path * -DestinationPath ../ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.archive_ext }} -Force
239+ powershell Compress-Archive -Path * -DestinationPath ../ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.artifact_suffix }}${{ matrix. archive_ext }} -Force
193240 shell : powershell
194241
195242 - name : Create archive (macOS)
196243 if : startsWith(github.ref, 'refs/tags/') && matrix.goos == 'darwin'
197244 run : |
198245 cd release
199- zip -r ../ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.archive_ext }} .
246+ zip -r ../ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.artifact_suffix }}${{ matrix. archive_ext }} .
200247 shell : bash
201248
202249 - name : Create archive (Linux)
203250 if : startsWith(github.ref, 'refs/tags/') && matrix.goos == 'linux'
204251 run : |
205252 cd release
206- tar -czf ../ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.archive_ext }} .
253+ tar -czf ../ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.artifact_suffix }}${{ matrix. archive_ext }} .
207254 shell : bash
208255
209256 - name : Upload artifacts
210257 if : startsWith(github.ref, 'refs/tags/')
211258 uses : actions/upload-artifact@v4
212259 with :
213- name : ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}
214- path : ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.archive_ext }}
260+ name : ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.artifact_suffix }}
261+ path : ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.artifact_suffix }}${{ matrix. archive_ext }}
215262 retention-days : 30
216263
217264 release :
0 commit comments