Merge branch 'main' of https://github.com/youtubediscord/zapret-kvn #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build & Release | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Determine version | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| shell: pwsh | |
| run: | | |
| $tags = git tag --list "v*" --sort=-version:refname 2>$null | |
| if ($tags) { | |
| $latest = ($tags | Select-Object -First 1).Trim() | |
| # Strip "v" prefix and any suffix like "-beta" | |
| $clean = ($latest.TrimStart("v") -replace '-.*$','') | |
| $parts = $clean.Split(".") | |
| $major = [int]$parts[0] | |
| $minor = [int]$parts[1] | |
| $patch = [int]$parts[2] + 1 | |
| $version = "$major.$minor.$patch" | |
| } else { | |
| $version = "0.4.0" | |
| } | |
| echo "VERSION=$version" >> $env:GITHUB_ENV | |
| echo "RELEASE_TAG=v$version" >> $env:GITHUB_ENV | |
| Write-Host "Release version: $version (tag: v$version)" | |
| - name: Update version in constants.py | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| shell: pwsh | |
| run: | | |
| $file = "xray_fluent/constants.py" | |
| (Get-Content $file -Raw) -replace 'APP_VERSION = ".*?"', "APP_VERSION = `"$env:VERSION`"" | Set-Content $file -NoNewline | |
| Write-Host "Updated APP_VERSION to $env:VERSION" | |
| Get-Content $file | Select-String "APP_VERSION" | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: pip install -r requirements.txt | |
| - name: Download core binaries | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path core | Out-Null | |
| # ── Xray-core (includes xray.exe, geoip.dat, geosite.dat) ── | |
| Write-Host "Downloading Xray-core..." | |
| $xrayRelease = Invoke-RestMethod "https://api.github.com/repos/XTLS/Xray-core/releases/latest" | |
| $xrayAsset = $xrayRelease.assets | Where-Object { $_.name -match "Xray-windows-64\.zip$" } | |
| Invoke-WebRequest $xrayAsset.browser_download_url -OutFile xray.zip | |
| Expand-Archive xray.zip -DestinationPath _xray -Force | |
| Copy-Item _xray/xray.exe core/ | |
| Copy-Item _xray/geoip.dat core/ | |
| Copy-Item _xray/geosite.dat core/ | |
| Copy-Item _xray/LICENSE core/ | |
| Remove-Item -Recurse _xray, xray.zip | |
| # ── tun2socks ── | |
| Write-Host "Downloading tun2socks..." | |
| $tunRelease = Invoke-RestMethod "https://api.github.com/repos/xjasonlyu/tun2socks/releases/latest" | |
| $tunAsset = $tunRelease.assets | Where-Object { $_.name -match "windows-amd64\.zip$" } | |
| Invoke-WebRequest $tunAsset.browser_download_url -OutFile tun2socks.zip | |
| Expand-Archive tun2socks.zip -DestinationPath _tun -Force | |
| Get-ChildItem _tun -Recurse -Filter "*.exe" | ForEach-Object { Copy-Item $_.FullName core/tun2socks.exe } | |
| Remove-Item -Recurse _tun, tun2socks.zip | |
| # ── wintun ── | |
| Write-Host "Downloading wintun..." | |
| Invoke-WebRequest "https://www.wintun.net/builds/wintun-0.14.1.zip" -OutFile wintun.zip | |
| Expand-Archive wintun.zip -DestinationPath _wintun -Force | |
| Copy-Item _wintun/wintun/bin/amd64/wintun.dll core/ | |
| Remove-Item -Recurse _wintun, wintun.zip | |
| # ── sing-box ── | |
| Write-Host "Downloading sing-box..." | |
| $sbRelease = Invoke-RestMethod "https://api.github.com/repos/SagerNet/sing-box/releases/latest" | |
| $sbAsset = $sbRelease.assets | Where-Object { $_.name -match "windows-amd64\.zip$" -and $_.name -notmatch "\.sig" } | |
| Invoke-WebRequest $sbAsset.browser_download_url -OutFile singbox.zip | |
| Expand-Archive singbox.zip -DestinationPath _sb -Force | |
| Get-ChildItem _sb -Recurse -Filter "sing-box.exe" | ForEach-Object { Copy-Item $_.FullName core/sing-box.exe } | |
| Remove-Item -Recurse _sb, singbox.zip | |
| Write-Host "Core binaries ready:" | |
| Get-ChildItem core/ | |
| - name: Build with PyInstaller | |
| shell: pwsh | |
| run: | | |
| python -m PyInstaller main.py ` | |
| --name ZapretKVN ` | |
| --noconfirm --clean --console --onedir ` | |
| --uac-admin ` | |
| --manifest uac_admin.manifest ` | |
| --hidden-import win32comext ` | |
| --hidden-import win32comext.shell ` | |
| --hidden-import win32comext.shell.shellcon | |
| Copy-Item -Recurse core dist/ZapretKVN/core | |
| Write-Host "Build complete:" | |
| Get-ChildItem dist/ZapretKVN/ | Format-Table Name, Length | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ZapretKVN-portable | |
| path: dist/ZapretKVN/ | |
| # ── Release on every push to main ── | |
| - name: Create release archives | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| shell: pwsh | |
| run: | | |
| cd dist/ZapretKVN | |
| 7z a -tzip -mx=5 "../ZapretKVN-v$env:VERSION-windows-x64.zip" * | |
| 7z a -t7z -mx=5 "../ZapretKVN-v$env:VERSION-windows-x64.7z" * | |
| cd .. | |
| Write-Host "Release archives:" | |
| Get-ChildItem *.zip, *.7z | Format-Table Name, Length | |
| - name: Create GitHub Release | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ env.RELEASE_TAG }} | |
| name: "zapret kvn ${{ env.RELEASE_TAG }}" | |
| generate_release_notes: true | |
| make_latest: true | |
| files: | | |
| dist/ZapretKVN-*-windows-x64.zip | |
| dist/ZapretKVN-*-windows-x64.7z | |
| - name: Commit version bump | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add xray_fluent/constants.py | |
| git diff --cached --quiet || git commit -m "v${{ env.VERSION }} [skip ci]" && git push |