Update default.json #72
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() | |
| $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.5.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 ── | |
| 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/ | |
| 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 (latest, including pre-release) ── | |
| Write-Host "Downloading sing-box..." | |
| $sbReleases = Invoke-RestMethod "https://api.github.com/repos/SagerNet/sing-box/releases?per_page=10" | |
| $sbRelease = $sbReleases | Where-Object { -not $_.draft } | Select-Object -First 1 | |
| Write-Host "Using sing-box $($sbRelease.tag_name)" | |
| $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 ` | |
| --hidden-import encodings.idna | |
| Copy-Item -Recurse core dist/ZapretKVN/core | |
| # Copy zapret/ (presets, binaries, lists — tracked in git) | |
| if (Test-Path zapret) { | |
| Copy-Item -Recurse zapret dist/ZapretKVN/zapret | |
| } | |
| # Copy raw config templates for first-run users | |
| if (Test-Path data/templates) { | |
| New-Item -ItemType Directory -Force -Path dist/ZapretKVN/data | Out-Null | |
| Copy-Item -Recurse data/templates dist/ZapretKVN/data/templates | |
| } | |
| 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 push to main ── | |
| - name: Create release archives | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| shell: pwsh | |
| run: | | |
| cd dist/ZapretKVN | |
| # Self-extracting exe for manual install | |
| 7z a -t7z -mx=5 -sfx "../ZapretKVN-v$env:VERSION-windows-x64.exe" * | |
| # Zip for auto-updater | |
| 7z a -tzip -mx=5 "../ZapretKVN-v$env:VERSION-windows-x64.zip" * | |
| $zipPath = "../ZapretKVN-v$env:VERSION-windows-x64.zip" | |
| $zipHash = (Get-FileHash $zipPath -Algorithm SHA256).Hash.ToLower() | |
| Set-Content "$zipPath.sha256" -Value $zipHash -Encoding ASCII | |
| # 7z archive | |
| 7z a -t7z -mx=5 "../ZapretKVN-v$env:VERSION-windows-x64.7z" * | |
| cd .. | |
| Write-Host "Release archives:" | |
| Get-ChildItem *.exe, *.zip, *.7z, *.sha256 | 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.exe | |
| dist/ZapretKVN-*-windows-x64.zip | |
| dist/ZapretKVN-*-windows-x64.7z | |
| dist/ZapretKVN-*-windows-x64.zip.sha256 | |
| - name: Commit version bump | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| shell: bash | |
| 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 | |
| if ! git diff --cached --quiet; then | |
| git commit -m "v$VERSION [skip ci]" | |
| git push | |
| fi |