-
Notifications
You must be signed in to change notification settings - Fork 10
160 lines (137 loc) · 6.25 KB
/
Copy pathbuild.yml
File metadata and controls
160 lines (137 loc) · 6.25 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
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=9 -mfb=258 -mpass=15 "../ZapretKVN-v$env:VERSION-windows-x64.zip" *
7z a -t7z -mx=9 -mfb=273 -ms=on -md=64m -mmt=on "../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