|
| 1 | +name: Build & Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master, main] |
| 6 | + tags: ["v*"] |
| 7 | + pull_request: |
| 8 | + branches: [master, main] |
| 9 | + workflow_dispatch: |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: write |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: windows-latest |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Setup Python |
| 21 | + uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: "3.12" |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: pip install -r requirements.txt |
| 27 | + |
| 28 | + - name: Download core binaries |
| 29 | + shell: pwsh |
| 30 | + run: | |
| 31 | + New-Item -ItemType Directory -Force -Path core | Out-Null |
| 32 | +
|
| 33 | + # ── Xray-core (includes xray.exe, geoip.dat, geosite.dat) ── |
| 34 | + Write-Host "Downloading Xray-core..." |
| 35 | + $xrayRelease = Invoke-RestMethod "https://api.github.com/repos/XTLS/Xray-core/releases/latest" |
| 36 | + $xrayAsset = $xrayRelease.assets | Where-Object { $_.name -match "Xray-windows-64\.zip$" } |
| 37 | + Invoke-WebRequest $xrayAsset.browser_download_url -OutFile xray.zip |
| 38 | + Expand-Archive xray.zip -DestinationPath _xray -Force |
| 39 | + Copy-Item _xray/xray.exe core/ |
| 40 | + Copy-Item _xray/geoip.dat core/ |
| 41 | + Copy-Item _xray/geosite.dat core/ |
| 42 | + Copy-Item _xray/LICENSE core/ |
| 43 | + Remove-Item -Recurse _xray, xray.zip |
| 44 | +
|
| 45 | + # ── tun2socks ── |
| 46 | + Write-Host "Downloading tun2socks..." |
| 47 | + $tunRelease = Invoke-RestMethod "https://api.github.com/repos/xjasonlyu/tun2socks/releases/latest" |
| 48 | + $tunAsset = $tunRelease.assets | Where-Object { $_.name -match "windows-amd64\.zip$" } |
| 49 | + Invoke-WebRequest $tunAsset.browser_download_url -OutFile tun2socks.zip |
| 50 | + Expand-Archive tun2socks.zip -DestinationPath _tun -Force |
| 51 | + Get-ChildItem _tun -Recurse -Filter "*.exe" | ForEach-Object { Copy-Item $_.FullName core/tun2socks.exe } |
| 52 | + Remove-Item -Recurse _tun, tun2socks.zip |
| 53 | +
|
| 54 | + # ── wintun ── |
| 55 | + Write-Host "Downloading wintun..." |
| 56 | + Invoke-WebRequest "https://www.wintun.net/builds/wintun-0.14.1.zip" -OutFile wintun.zip |
| 57 | + Expand-Archive wintun.zip -DestinationPath _wintun -Force |
| 58 | + Copy-Item _wintun/wintun/bin/amd64/wintun.dll core/ |
| 59 | + Remove-Item -Recurse _wintun, wintun.zip |
| 60 | +
|
| 61 | + # ── sing-box ── |
| 62 | + Write-Host "Downloading sing-box..." |
| 63 | + $sbRelease = Invoke-RestMethod "https://api.github.com/repos/SagerNet/sing-box/releases/latest" |
| 64 | + $sbAsset = $sbRelease.assets | Where-Object { $_.name -match "windows-amd64\.zip$" -and $_.name -notmatch "\.sig" } |
| 65 | + Invoke-WebRequest $sbAsset.browser_download_url -OutFile singbox.zip |
| 66 | + Expand-Archive singbox.zip -DestinationPath _sb -Force |
| 67 | + Get-ChildItem _sb -Recurse -Filter "sing-box.exe" | ForEach-Object { Copy-Item $_.FullName core/sing-box.exe } |
| 68 | + Remove-Item -Recurse _sb, singbox.zip |
| 69 | +
|
| 70 | + Write-Host "Core binaries ready:" |
| 71 | + Get-ChildItem core/ |
| 72 | +
|
| 73 | + - name: Build with PyInstaller |
| 74 | + shell: pwsh |
| 75 | + run: | |
| 76 | + python -m PyInstaller main.py ` |
| 77 | + --name ZapretKVN ` |
| 78 | + --noconfirm --clean --console --onedir ` |
| 79 | + --uac-admin ` |
| 80 | + --manifest uac_admin.manifest ` |
| 81 | + --hidden-import win32comext ` |
| 82 | + --hidden-import win32comext.shell ` |
| 83 | + --hidden-import win32comext.shell.shellcon |
| 84 | +
|
| 85 | + # Copy core/ into dist |
| 86 | + Copy-Item -Recurse core dist/ZapretKVN/core |
| 87 | +
|
| 88 | + Write-Host "Build complete:" |
| 89 | + Get-ChildItem dist/ZapretKVN/ | Format-Table Name, Length |
| 90 | +
|
| 91 | + - name: Upload build artifact |
| 92 | + uses: actions/upload-artifact@v4 |
| 93 | + with: |
| 94 | + name: ZapretKVN-portable |
| 95 | + path: dist/ZapretKVN/ |
| 96 | + |
| 97 | + # ── Release (only on tag push v*) ── |
| 98 | + |
| 99 | + - name: Create release archives |
| 100 | + if: startsWith(github.ref, 'refs/tags/v') |
| 101 | + shell: pwsh |
| 102 | + run: | |
| 103 | + $version = "${{ github.ref_name }}" |
| 104 | + cd dist/ZapretKVN |
| 105 | +
|
| 106 | + # ZIP |
| 107 | + Compress-Archive -Path * -DestinationPath "../ZapretKVN-${version}-windows-x64.zip" |
| 108 | +
|
| 109 | + # 7z |
| 110 | + 7z a "../ZapretKVN-${version}-windows-x64.7z" * -mx9 |
| 111 | +
|
| 112 | + cd .. |
| 113 | + Write-Host "Release archives:" |
| 114 | + Get-ChildItem *.zip, *.7z | Format-Table Name, Length |
| 115 | +
|
| 116 | + - name: Create GitHub Release |
| 117 | + if: startsWith(github.ref, 'refs/tags/v') |
| 118 | + uses: softprops/action-gh-release@v2 |
| 119 | + with: |
| 120 | + name: "zapret kvn ${{ github.ref_name }}" |
| 121 | + generate_release_notes: true |
| 122 | + files: | |
| 123 | + dist/ZapretKVN-*-windows-x64.zip |
| 124 | + dist/ZapretKVN-*-windows-x64.7z |
0 commit comments