-
Notifications
You must be signed in to change notification settings - Fork 934
170 lines (150 loc) · 5.04 KB
/
Copy pathbuild.yml
File metadata and controls
170 lines (150 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Build and Release
on:
push:
branches:
- main
- master
tags:
- 'v*'
pull_request:
branches:
- main
- master
workflow_dispatch:
jobs:
build:
strategy:
matrix:
include:
- os: windows-latest
goos: windows
goarch: amd64
exe_ext: .exe
archive_format: zip
archive_ext: .zip
- os: macos-13
goos: darwin
goarch: amd64
exe_ext: ''
archive_format: zip
archive_ext: .zip
- os: macos-14
goos: darwin
goarch: arm64
exe_ext: ''
archive_format: zip
archive_ext: .zip
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Initialize Go module
run: |
go mod init ech-workers || true
go mod tidy
- name: Build Go executable
run: |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ech-workers${{ matrix.exe_ext }} ech-workers.go
shell: bash
- name: Set up Python
if: startsWith(github.ref, 'refs/tags/')
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install PyInstaller and dependencies
if: startsWith(github.ref, 'refs/tags/')
run: |
python -m pip install --upgrade pip
pip install pyinstaller PyQt5 pystray Pillow
- name: Build Python executable
if: startsWith(github.ref, 'refs/tags/')
run: |
# PyInstaller 会自动使用当前系统架构
# macos-13 = Intel (x86_64), macos-14 = Apple Silicon (arm64)
pyinstaller --onefile --windowed --name ECHWorkersGUI gui.py
shell: bash
- name: Prepare release files
if: startsWith(github.ref, 'refs/tags/')
run: |
mkdir -p release
# 复制 Go 可执行文件
cp ech-workers${{ matrix.exe_ext }} release/
# 复制 Python 打包后的可执行文件
if [ "${{ matrix.goos }}" == "windows" ]; then
if [ -f "dist/ECHWorkersGUI.exe" ]; then
cp dist/ECHWorkersGUI.exe release/
fi
else
if [ -f "dist/ECHWorkersGUI" ]; then
cp dist/ECHWorkersGUI release/
chmod +x release/ECHWorkersGUI
fi
fi
# 创建 README
{
echo "ECH Workers Client"
echo ""
echo "Files:"
echo "- ech-workers(.exe): Go compiled core proxy program"
if [ "${{ matrix.goos }}" == "windows" ]; then
echo "- ECHWorkersGUI.exe: Python GUI client (standalone executable)"
else
echo "- ECHWorkersGUI: Python GUI client (standalone executable)"
fi
echo ""
echo "Usage:"
if [ "${{ matrix.goos }}" == "windows" ]; then
echo "1. Double-click ECHWorkersGUI.exe to launch the GUI"
echo "2. Or run ech-workers.exe from command line"
else
echo "1. Run ./ECHWorkersGUI to launch the GUI"
echo "2. Or run ./ech-workers from command line"
fi
echo ""
echo "System Requirements:"
echo "- Windows: Windows 10+"
echo "- macOS: macOS 10.13+"
echo "- No Python installation required (standalone executables)"
} > release/README.txt
shell: bash
- name: Create archive (Windows)
if: startsWith(github.ref, 'refs/tags/') && matrix.goos == 'windows'
run: |
cd release
powershell Compress-Archive -Path * -DestinationPath ../ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.archive_ext }} -Force
shell: powershell
- name: Create archive (macOS/Linux)
if: startsWith(github.ref, 'refs/tags/') && matrix.goos != 'windows'
run: |
cd release
zip -r ../ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.archive_ext }} .
shell: bash
- name: Upload artifacts
if: startsWith(github.ref, 'refs/tags/')
uses: actions/upload-artifact@v4
with:
name: ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}
path: ECHWorkers-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.archive_ext }}
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Create release
uses: softprops/action-gh-release@v1
with:
files: |
artifacts/**/*.zip
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}