Skip to content

Commit 394e117

Browse files
GitHub Actions: Add wintun.dll into Windows zips; Workflow refinement (#5501)
For #5464
1 parent 446df14 commit 394e117

File tree

3 files changed

+164
-29
lines changed

3 files changed

+164
-29
lines changed

.github/workflows/release-win7.yml

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ jobs:
1818
path: resources
1919
key: xray-geodat-
2020

21+
- name: Restore Wintun Cache
22+
uses: actions/cache/restore@v5
23+
with:
24+
path: resources
25+
key: xray-wintun-
26+
2127
- name: Check Assets Existence
2228
id: check-assets
2329
run: |
@@ -34,6 +40,18 @@ jobs:
3440
break
3541
fi
3642
done
43+
LIST=('amd64' 'x86')
44+
for ARCHITECTURE in "${LIST[@]}"
45+
do
46+
echo -e "Checking wintun.dll for ${ARCHITECTURE}..."
47+
if [ -s "./resources/wintun/bin/${ARCHITECTURE}/wintun.dll" ]; then
48+
echo -e "wintun.dll for ${ARCHITECTURE} exists."
49+
else
50+
echo -e "wintun.dll for ${ARCHITECTURE} is missing."
51+
echo "missing=true" >> $GITHUB_OUTPUT
52+
break
53+
fi
54+
done
3755
3856
- name: Sleep for 90 seconds if Assets Missing
3957
if: steps.check-assets.outputs.missing == 'true'
@@ -95,8 +113,6 @@ jobs:
95113
COMMID=$(git describe --always --dirty)
96114
echo 'Building Xray for Windows 7...'
97115
go build -o build_assets/xray.exe -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
98-
echo 'CreateObject("Wscript.Shell").Run "xray.exe -config config.json",0' > build_assets/xray_no_window.vbs
99-
echo 'Start-Process -FilePath ".\xray.exe" -ArgumentList "-config .\config.json" -WindowStyle Hidden' > build_assets/xray_no_window.ps1
100116
# The line below is for without running conhost.exe version. Commented for not being used. Provided for reference.
101117
# go build -o build_assets/wxray.exe -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-H windowsgui -X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
102118
@@ -106,9 +122,29 @@ jobs:
106122
path: resources
107123
key: xray-geodat-
108124

125+
- name: Restore Wintun Cache
126+
uses: actions/cache/restore@v5
127+
with:
128+
path: resources
129+
key: xray-wintun-
130+
131+
- name: Add additional assets into package
132+
run: |
133+
mv -f resources/geo* build_assets/
134+
if [[ ${GOOS} == 'windows' ]]; then
135+
echo 'CreateObject("Wscript.Shell").Run "xray.exe -config config.json",0' > build_assets/xray_no_window.vbs
136+
echo 'Start-Process -FilePath ".\xray.exe" -ArgumentList "-config .\config.json" -WindowStyle Hidden' > build_assets/xray_no_window.ps1
137+
if [[ ${GOARCH} == 'amd64' ]]; then
138+
mv resources/wintun/bin/amd64/wintun.dll build_assets/
139+
fi
140+
if [[ ${GOARCH} == '386' ]]; then
141+
mv resources/wintun/bin/x86/wintun.dll build_assets/
142+
fi
143+
mv resources/wintun/LICENSE.txt build_assets/LICENSE-wintun.txt
144+
fi
145+
109146
- name: Copy README.md & LICENSE
110147
run: |
111-
mv -f resources/* build_assets
112148
cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md
113149
cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
114150
@@ -127,17 +163,6 @@ jobs:
127163
openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST
128164
done
129165
130-
- name: Change the name
131-
run: |
132-
mv build_assets Xray-${{ env.ASSET_NAME }}
133-
134-
- name: Upload files to Artifacts
135-
uses: actions/upload-artifact@v6
136-
with:
137-
name: Xray-${{ env.ASSET_NAME }}
138-
path: |
139-
./Xray-${{ env.ASSET_NAME }}/*
140-
141166
- name: Upload binaries to release
142167
uses: svenstaro/upload-release-action@v2
143168
if: github.event_name == 'release'
@@ -146,3 +171,10 @@ jobs:
146171
file: ./Xray-${{ env.ASSET_NAME }}.zip*
147172
tag: ${{ github.ref }}
148173
file_glob: true
174+
175+
- name: Upload files to Artifacts
176+
uses: actions/upload-artifact@v6
177+
with:
178+
name: Xray-${{ env.ASSET_NAME }}
179+
path: |
180+
./build_assets/*

.github/workflows/release.yml

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ jobs:
1818
path: resources
1919
key: xray-geodat-
2020

21+
- name: Restore Wintun Cache
22+
uses: actions/cache/restore@v5
23+
with:
24+
path: resources
25+
key: xray-wintun-
26+
2127
- name: Check Assets Existence
2228
id: check-assets
2329
run: |
@@ -34,6 +40,18 @@ jobs:
3440
break
3541
fi
3642
done
43+
LIST=('amd64' 'x86' 'arm64' 'arm')
44+
for ARCHITECTURE in "${LIST[@]}"
45+
do
46+
echo -e "Checking wintun.dll for ${ARCHITECTURE}..."
47+
if [ -s "./resources/wintun/bin/${ARCHITECTURE}/wintun.dll" ]; then
48+
echo -e "wintun.dll for ${ARCHITECTURE} exists."
49+
else
50+
echo -e "wintun.dll for ${ARCHITECTURE} is missing."
51+
echo "missing=true" >> $GITHUB_OUTPUT
52+
break
53+
fi
54+
done
3755
3856
- name: Trigger Asset Update Workflow if Assets Missing
3957
if: steps.check-assets.outputs.missing == 'true'
@@ -191,8 +209,6 @@ jobs:
191209
if [[ ${GOOS} == 'windows' ]]; then
192210
echo 'Building Xray for Windows...'
193211
go build -o build_assets/xray.exe -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
194-
echo 'CreateObject("Wscript.Shell").Run "xray.exe -config config.json",0' > build_assets/xray_no_window.vbs
195-
echo 'Start-Process -FilePath ".\xray.exe" -ArgumentList "-config .\config.json" -WindowStyle Hidden' > build_assets/xray_no_window.ps1
196212
# The line below is for without running conhost.exe version. Commented for not being used. Provided for reference.
197213
# go build -o build_assets/wxray.exe -trimpath -buildvcs=false -gcflags="all=-l=4" -ldflags="-H windowsgui -X github.com/xtls/xray-core/core.build=${COMMID} -s -w -buildid=" -v ./main
198214
else
@@ -212,9 +228,36 @@ jobs:
212228
path: resources
213229
key: xray-geodat-
214230

231+
- name: Restore Wintun Cache
232+
if: matrix.goos == 'windows'
233+
uses: actions/cache/restore@v5
234+
with:
235+
path: resources
236+
key: xray-wintun-
237+
238+
- name: Add additional assets into package
239+
run: |
240+
mv -f resources/geo* build_assets/
241+
if [[ ${GOOS} == 'windows' ]]; then
242+
echo 'CreateObject("Wscript.Shell").Run "xray.exe -config config.json",0' > build_assets/xray_no_window.vbs
243+
echo 'Start-Process -FilePath ".\xray.exe" -ArgumentList "-config .\config.json" -WindowStyle Hidden' > build_assets/xray_no_window.ps1
244+
if [[ ${GOARCH} == 'amd64' ]]; then
245+
mv resources/wintun/bin/amd64/wintun.dll build_assets/
246+
fi
247+
if [[ ${GOARCH} == '386' ]]; then
248+
mv resources/wintun/bin/x86/wintun.dll build_assets/
249+
fi
250+
if [[ ${GOARCH} == 'arm64' ]]; then
251+
mv resources/wintun/bin/arm64/wintun.dll build_assets/
252+
fi
253+
if [[ ${GOARCH} == 'arm' ]]; then
254+
mv resources/wintun/bin/arm/wintun.dll build_assets/
255+
fi
256+
mv resources/wintun/LICENSE.txt build_assets/LICENSE-wintun.txt
257+
fi
258+
215259
- name: Copy README.md & LICENSE
216260
run: |
217-
mv -f resources/* build_assets
218261
cp ${GITHUB_WORKSPACE}/README.md ./build_assets/README.md
219262
cp ${GITHUB_WORKSPACE}/LICENSE ./build_assets/LICENSE
220263
@@ -233,17 +276,6 @@ jobs:
233276
openssl dgst -$METHOD $FILE | sed 's/([^)]*)//g' >>$DGST
234277
done
235278
236-
- name: Change the name
237-
run: |
238-
mv build_assets Xray-${{ env.ASSET_NAME }}
239-
240-
- name: Upload files to Artifacts
241-
uses: actions/upload-artifact@v6
242-
with:
243-
name: Xray-${{ env.ASSET_NAME }}
244-
path: |
245-
./Xray-${{ env.ASSET_NAME }}/*
246-
247279
- name: Upload binaries to release
248280
uses: svenstaro/upload-release-action@v2
249281
if: github.event_name == 'release'
@@ -252,3 +284,10 @@ jobs:
252284
file: ./Xray-${{ env.ASSET_NAME }}.zip*
253285
tag: ${{ github.ref }}
254286
file_glob: true
287+
288+
- name: Upload files to Artifacts
289+
uses: actions/upload-artifact@v6
290+
with:
291+
name: Xray-${{ env.ASSET_NAME }}
292+
path: |
293+
./build_assets/*

.github/workflows/scheduled-assets-update.yml

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ name: Scheduled assets update
44
# routine manner, for example: GeoIP/GeoSite.
55
# Currently updating:
66
# - Geodat (GeoIP/Geosite)
7+
# - Wintun (wintun.dll)
78

89
on:
910
workflow_dispatch:
@@ -21,7 +22,7 @@ on:
2122

2223
jobs:
2324
geodat:
24-
if: github.event.schedule == '30 22 * * *' || github.event_name == 'push'|| github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
25+
if: github.event.schedule == '30 22 * * *' || github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
2526
runs-on: ubuntu-latest
2627
steps:
2728
- name: Restore Geodat Cache
@@ -63,3 +64,66 @@ jobs:
6364
with:
6465
path: resources
6566
key: xray-geodat-${{ github.sha }}-${{ github.run_number }}
67+
68+
wintun:
69+
if: github.event.schedule == '30 22 * * *' || github.event_name == 'push' || github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
70+
runs-on: ubuntu-latest
71+
steps:
72+
- name: Restore Wintun Cache
73+
uses: actions/cache/restore@v5
74+
with:
75+
path: resources
76+
key: xray-wintun-
77+
78+
- name: Force downloading if run manually or on file update
79+
if: github.event_name == 'workflow_dispatch' || github.event_name == 'push'
80+
run: |
81+
echo "FORCE_UPDATE=true" >> $GITHUB_ENV
82+
83+
- name: Update Wintun
84+
id: update
85+
uses: nick-fields/retry@v3
86+
with:
87+
timeout_minutes: 60
88+
retry_wait_seconds: 60
89+
max_attempts: 60
90+
command: |
91+
[ -d 'resources' ] || mkdir resources
92+
LIST=('amd64' 'x86' 'arm64' 'arm')
93+
for ARCHITECTURE in "${LIST[@]}"
94+
do
95+
FILE_PATH="resources/wintun/bin/${ARCHITECTURE}/wintun.dll"
96+
echo -e "Checking if wintun.dll for ${ARCHITECTURE} exists..."
97+
if [ -s "./resources/wintun/bin/${ARCHITECTURE}/wintun.dll" ]; then
98+
echo -e "wintun.dll for ${ARCHITECTURE} exists"
99+
continue
100+
else
101+
echo -e "wintun.dll for ${ARCHITECTURE} is missing"
102+
missing=true
103+
fi
104+
done
105+
if [ -s "./resources/wintun/LICENSE.txt" ]; then
106+
echo -e "LICENSE for Wintun exists"
107+
else
108+
echo -e "LICENSE for Wintun is missing"
109+
missing=true
110+
fi
111+
if [[ -v FORCE_UPDATE ]]; then
112+
missing=true
113+
fi
114+
if [[ "$missing" == true ]]; then
115+
FILENAME=wintun.zip
116+
DOWNLOAD_FILE=wintun-0.14.1.zip
117+
echo -e "Downloading https://www.wintun.net/builds/${DOWNLOAD_FILE}..."
118+
curl -L "https://www.wintun.net/builds/${DOWNLOAD_FILE}" -o "${FILENAME}"
119+
echo -e "Unpacking wintun..."
120+
unzip -u ${FILENAME} -d resources/
121+
echo "unhit=true" >> $GITHUB_OUTPUT
122+
fi
123+
124+
- name: Save Wintun Cache
125+
uses: actions/cache/save@v5
126+
if: ${{ steps.update.outputs.unhit }}
127+
with:
128+
path: resources
129+
key: xray-wintun-${{ github.sha }}-${{ github.run_number }}

0 commit comments

Comments
 (0)