1+ name : Build Windows Packages
2+
3+ on :
4+ workflow_dispatch :
5+ push :
6+ branches :
7+ - main
8+ - master
9+ tags :
10+ - " v*"
11+
12+ jobs :
13+ build :
14+ runs-on : windows-latest
15+ strategy :
16+ fail-fast : false
17+ matrix :
18+ target :
19+ - name : win7
20+ python-version : " 3.8"
21+ - name : win10
22+ python-version : " 3.11"
23+
24+ steps :
25+ - name : Checkout
26+ uses : actions/checkout@v4
27+
28+ - name : Setup Python
29+ uses : actions/setup-python@v5
30+ with :
31+ python-version : ${{ matrix.target.python-version }}
32+ architecture : x64
33+
34+ - name : Install dependencies
35+ shell : powershell
36+ run : |
37+ python -m pip install --upgrade pip
38+ pip install -r requirements.txt
39+
40+ - name : Build executables
41+ shell : powershell
42+ run : |
43+ if (Test-Path dist) { Remove-Item dist -Recurse -Force }
44+ if (Test-Path build) { Remove-Item build -Recurse -Force }
45+ python -m PyInstaller --clean --noconfirm package\teacher.spec
46+ python -m PyInstaller --clean --noconfirm package\agent.spec
47+
48+ - name : Download mihomo for network restrict
49+ shell : powershell
50+ run : |
51+ $mihomoUrl = "https://github.com/MetaCubeX/mihomo/releases/download/v1.19.24/mihomo-windows-amd64-compatible-v1.19.24.zip"
52+ $mihomoZip = "mihomo-windows-amd64-compatible-v1.19.24.zip"
53+
54+ if (Test-Path $mihomoZip) { Remove-Item $mihomoZip -Force }
55+ if (Test-Path "mihomo-windows-amd64-compatible.exe") { Remove-Item "mihomo-windows-amd64-compatible.exe" -Force }
56+ if (Test-Path "mihomo.exe") { Remove-Item "mihomo.exe" -Force }
57+
58+ Invoke-WebRequest -Uri $mihomoUrl -OutFile $mihomoZip
59+ Expand-Archive -Path $mihomoZip -DestinationPath "." -Force
60+ Rename-Item -Path "mihomo-windows-amd64-compatible.exe" -NewName "mihomo.exe" -Force
61+
62+ - name : Create zip packages
63+ shell : powershell
64+ run : |
65+ $version = "${{ github.ref_name }}"
66+ if ("${{ github.ref_type }}" -ne "tag") {
67+ $sha = "${{ github.sha }}"
68+ $version = "sha-$($sha.Substring(0, 7))"
69+ }
70+
71+ $outDir = "out/${{ matrix.target.name }}"
72+ $agentDir = "$outDir/LabAgent"
73+ $teacherDir = "$outDir/LabTeacher"
74+ $agentZip = "LabAgent-${{ matrix.target.name }}-$version.zip"
75+ $teacherZip = "LabTeacher-${{ matrix.target.name }}-$version.zip"
76+
77+ New-Item -ItemType Directory -Path "$agentDir/configs" -Force | Out-Null
78+ New-Item -ItemType Directory -Path "$teacherDir/configs" -Force | Out-Null
79+
80+ Copy-Item "dist/LabAgent.exe" "$agentDir/LabAgent.exe" -Force
81+ Copy-Item "mihomo.exe" "$agentDir/mihomo.exe" -Force
82+ Copy-Item "dist/LabTeacher.exe" "$teacherDir/LabTeacher.exe" -Force
83+ Copy-Item "configs/agent.json" "$agentDir/configs/agent.json" -Force
84+ Copy-Item "configs/teacher.json" "$teacherDir/configs/teacher.json" -Force
85+
86+ if (Test-Path "$outDir/$agentZip") { Remove-Item "$outDir/$agentZip" -Force }
87+ if (Test-Path "$outDir/$teacherZip") { Remove-Item "$outDir/$teacherZip" -Force }
88+ Compress-Archive -Path "$agentDir/*" -DestinationPath "$outDir/$agentZip"
89+ Compress-Archive -Path "$teacherDir/*" -DestinationPath "$outDir/$teacherZip"
90+
91+ - name : Upload artifacts
92+ uses : actions/upload-artifact@v4
93+ with :
94+ name : packages-${{ matrix.target.name }}
95+ path : out/${{ matrix.target.name }}/*.zip
96+
97+ release :
98+ if : startsWith(github.ref, 'refs/tags/')
99+ needs : build
100+ runs-on : windows-latest
101+ permissions :
102+ contents : write
103+ steps :
104+ - name : Download all package artifacts
105+ uses : actions/download-artifact@v4
106+ with :
107+ pattern : packages-*
108+ path : release
109+ merge-multiple : true
110+
111+ - name : Publish GitHub Release assets
112+ uses : softprops/action-gh-release@v2
113+ with :
114+ files : release/*.zip
0 commit comments