forked from v2rayA/v2rayA
-
Notifications
You must be signed in to change notification settings - Fork 0
759 lines (756 loc) · 32.1 KB
/
release_main.yml
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
name: Build & Release v2rayA
on:
workflow_dispatch:
push:
branches: [ main ]
tags:
- v*
paths:
- "**/*.go"
- "go.mod"
- "go.sum"
- "gui/**"
- ".github/workflows/*.yml"
pull_request:
types: [opened, synchronize, reopened]
paths:
- .github/workflows/release_main.yml
jobs:
Build_v2rayA_Web:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: lts/*
cache: 'yarn'
cache-dependency-path: gui/yarn.lock
- name: Install Dependencies
run: |
sudo apt-get update -y && sudo apt-get install -y gzip
- name: Build GUI
run: |
yarn --cwd gui --check-files
yarn --cwd gui build
echo "Use tar to generate web.tar.gz..."
tar -zcvf web.tar.gz web/
- name: Upload Zip File to Artifacts
uses: actions/upload-artifact@v3
with:
path: web/*
name: web
- name: Upload the tar archive to Artifacts
uses: nanoufo/[email protected]
with:
path: |
web.tar.gz
Build_v2rayA_Binaries:
strategy:
matrix:
goos: [ linux ]
goarch: [ amd64, arm64, 386, riscv64, mips64, mips64le, mipsle, mips ]
include:
# BEGIN Linux ARM 5 6 7
- goos: linux
goarch: arm
goarm: 7
- goos: linux
goarch: arm
goarm: 6
- goos: linux
goarch: arm
goarm: 5
# END Linux ARM 5 6 7
# BEGIN Windows
- goos: windows
goarch: amd64
win_suf: .exe
- goos: windows
goarch: arm64
win_suf: .exe
# END Windows
# BEGIN macOS
- goos: darwin
goarch: amd64
- goos: darwin
goarch: arm64
# END macOS
# BEGIN BSD
- goos: freebsd
goarch: amd64
- goos: freebsd
goarch: arm64
- goos: openbsd
goarch: amd64
- goos: openbsd
goarch: arm64
# END BSD
fail-fast: false
runs-on: ubuntu-22.04
needs: [Build_v2rayA_Web]
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
WIN_SUF: ${{ matrix.win_suf }}
CGO_ENABLED: 0
NAME: v2raya
DESC: "A web GUI client of Project V which supports VMess, VLESS, SS, SSR, Trojan, Tuic and Juicity protocols"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: web
path: service/server/router/web
- name: Get Friendly File Name
shell: pwsh
id: get_filename
run: |
$build_name = $(((Get-Content ./install/friendly-filenames.json | ConvertFrom-Json)."${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}").friendlyName)
Write-Output "BUILD_NAME=$build_name" >> ${env:GITHUB_OUTPUT}
Write-Output "BUILD_NAME=$build_name" >> ${env:GITHUB_ENV}
- name: Check Version
id: prep
env:
REF: ${{ github.ref }}
run: |
echo "P_DIR=$(pwd)" >> $GITHUB_OUTPUT
if [[ "$REF" == "refs/tags/v"* ]]; then
tag=$(git describe --tags $(git rev-list --tags --max-count=1))
version=${tag:1}
else
date=$(git log -1 --format="%cd" --date=short | sed s/-//g)
count=$(git rev-list --count HEAD)
commit=$(git rev-parse --short HEAD)
version="unstable-$date.r${count}.$commit"
fi
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_ENV
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ^1.21
- name: Install Dependencies
run: |
sudo apt-get update -y && sudo apt-get install -y gzip
- name: Build v2rayA Binaries
id: build
run: |
for file in $(find service/server/router/web |grep -v png |grep -v index.html|grep -v .gz); do
if [ ! -d $file ];then
gzip -9 $file
fi
done
cd service
go build -ldflags="-X github.com/v2rayA/v2rayA/conf.Version=$VERSION -s -w" -o ../build_"$GOOS"_"$GOARCH""$GOARM"_"$VERSION""$WIN_SUF"
cd ..
mv build_"$GOOS"_"$GOARCH""$GOARM"_"$VERSION""$WIN_SUF" v2raya_"${{ steps.get_filename.outputs.BUILD_NAME }}"_"$VERSION""$WIN_SUF"
- name: Upload Artifact
uses: nanoufo/[email protected]
with:
path: |
v2raya_${{ steps.get_filename.outputs.BUILD_NAME }}_${{ steps.prep.outputs.VERSION }}${{ matrix.win_suf }}
Build_Windows_Installers:
runs-on: windows-latest
needs: [Build_v2rayA_Binaries]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check Version
id: prep
env:
REF: ${{ github.ref }}
shell: bash
run: |
echo "P_DIR=$(pwd)" >> $GITHUB_OUTPUT
if [[ "$REF" == "refs/tags/v"* ]]; then
tag=$(git describe --tags $(git rev-list --tags --max-count=1))
version=${tag:1}
else
date=$(git log -1 --format="%cd" --date=short | sed s/-//g)
count=$(git rev-list --count HEAD)
commit=$(git rev-parse --short HEAD)
version="unstable-$date.r${count}.$commit"
fi
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_ENV
- name: Download Artifact Windows x64
uses: actions/download-artifact@v3
with:
name: v2raya_windows_x64_${{ steps.prep.outputs.VERSION }}.exe
path: D:\Downloads
- name: Download Artifact Windows arm64
uses: actions/download-artifact@v3
with:
name: v2raya_windows_arm64_${{ steps.prep.outputs.VERSION }}.exe
path: D:\Downloads
- name: Install Inno Setup
shell: pwsh
run: |
choco install innosetup -y
- name: Build Windows Installer
shell: pwsh
run: |
## Create Destination Directory
New-Item -ItemType Directory -Path "D:\v2raya-x86_64-windows\data"
New-Item -ItemType Directory -Path "D:\v2raya-x86_64-windows\bin"
New-Item -ItemType Directory -Path "D:\v2raya-arm64-windows\data"
New-Item -ItemType Directory -Path "D:\v2raya-arm64-windows\bin"
## Copy v2rayA to Destination Directory
Copy-Item -Path D:\Downloads\v2raya_windows_arm64_${{ steps.prep.outputs.VERSION }}.exe -Destination D:\v2raya-arm64-windows\bin\v2raya.exe
Copy-Item -Path D:\Downloads\v2raya_windows_x64_${{ steps.prep.outputs.VERSION }}.exe -Destination D:\v2raya-x86_64-windows\bin\v2raya.exe
Copy-Item -Path ".\install\windows-inno\v2raya.ico" -Destination "D:\v2raya.ico"
## Download and extract v2ray
$Url_v2ray_x64 = "https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-windows-64.zip"
$Url_v2ray_A64 = "https://github.com/v2fly/v2ray-core/releases/latest/download/v2ray-windows-arm64-v8a.zip"
Invoke-WebRequest $Url_v2ray_x64 -OutFile "D:\v2ray-windows-x64.zip"
Expand-Archive -Path "D:\v2ray-windows-x64.zip" -DestinationPath "D:\v2raya-x86_64-windows\bin\"
Move-Item -Path "D:\v2raya-x86_64-windows\bin\*.dat" -Destination "D:\v2raya-x86_64-windows\data\"
Remove-Item -Path "D:\v2raya-x86_64-windows\bin\*.json" -Force -Recurse -ErrorAction SilentlyContinue
Invoke-WebRequest $Url_v2ray_A64 -OutFile "D:\v2ray-windows-A64.zip"
Expand-Archive -Path "D:\v2ray-windows-A64.zip" -DestinationPath "D:\v2raya-arm64-windows\bin\"
Move-Item -Path "D:\v2raya-arm64-windows\bin\*.dat" -Destination "D:\v2raya-arm64-windows\data\"
Remove-Item -Path "D:\v2raya-arm64-windows\bin\*.json" -Force -Recurse -ErrorAction SilentlyContinue
## Download WinSW
## WinSW said they have a native ARM64 version, but I cannot find it, so use net4 version instead on ARM-based Windows.
## See more in "https://visualstudiomagazine.com/articles/2022/08/12/net-framework-4-8-1.aspx"
$Url_WinSW = "https://github.com/winsw/winsw/releases/download/v3.0.0-alpha.11/WinSW-net461.exe"
Invoke-WebRequest $Url_WinSW -OutFile "D:\WinSW.exe"
Copy-Item -Path "D:\WinSW.exe" -Destination "D:\v2raya-x86_64-windows\v2rayA-service.exe"
Copy-Item -Path "D:\WinSW.exe" -Destination "D:\v2raya-arm64-windows\v2rayA-service.exe"
## Copy License and Service Config
Copy-Item -Path ".\LICENSE" -Destination "D:\LICENSE.txt"
Copy-Item -Path ".\install\windows-inno\v2rayA-service.xml" -Destination "D:\v2raya-x86_64-windows\v2rayA-service.xml"
Copy-Item -Path ".\install\windows-inno\v2rayA-service.xml" -Destination "D:\v2raya-arm64-windows\v2rayA-service.xml"
## Set Version
$(Get-Content -Path .\install\windows-inno\windows_x86_64.iss).replace("TheRealVersion", "${{ steps.prep.outputs.VERSION }}") | Out-File "D:\windows_x86_64.iss"
$(Get-Content -Path .\install\windows-inno\windows_arm64.iss).replace("TheRealVersion", "${{ steps.prep.outputs.VERSION }}") | Out-File "D:\windows_arm64.iss"
## Build Installer
& 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe' "D:\windows_x86_64.iss"
& 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe' "D:\windows_arm64.iss"
## Rename to Friendly Name
Copy-Item -Path D:\installer_windows_inno_x64.exe -Destination .\installer_windows_inno_x64_${{ steps.prep.outputs.VERSION }}.exe
Copy-Item -Path D:\installer_windows_inno_arm64.exe -Destination .\installer_windows_inno_arm64_${{ steps.prep.outputs.VERSION }}.exe
- name: Upload Artifact
uses: nanoufo/[email protected]
with:
path: |
installer_windows_inno_x64_${{ steps.prep.outputs.VERSION }}.exe
installer_windows_inno_arm64_${{ steps.prep.outputs.VERSION }}.exe
Build_Linux_Packages:
runs-on: ubuntu-22.04
needs: [Build_v2rayA_Binaries]
strategy:
matrix:
goos: [linux]
goarch: [amd64, arm64, 386, riscv64, mips64, mips64le, mipsle, mips]
include:
- goos: linux
goarch: arm
goarm: 7
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
GOARM: ${{ matrix.goarm }}
CGO_ENABLED: 0
NAME: v2raya
DESC: "A web GUI client of Project V which supports VMess, VLESS, SS, SSR, Trojan, Tuic and Juicity protocols"
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get Friendly File Name
shell: pwsh
id: get_filename
run: |
$build_name = $(((Get-Content ./install/friendly-filenames.json | ConvertFrom-Json)."${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}").friendlyName)
$friendly_arch = $((((Get-Content ./install/friendly-filenames.json | ConvertFrom-Json)."${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm }}").friendlyName).Split('_')[1])
Write-Output "BUILD_NAME=$build_name" >> ${env:GITHUB_OUTPUT}
Write-Output "BUILD_NAME=$build_name" >> ${env:GITHUB_ENV}
Write-Output "FRIENDLY_ARCH=$friendly_arch" >> ${env:GITHUB_OUTPUT}
Write-Output "FRIENDLY_ARCH=$friendly_arch" >> ${env:GITHUB_ENV}
- name: Check Version
id: prep
env:
REF: ${{ github.ref }}
run: |
echo "P_DIR=$(pwd)" >> $GITHUB_OUTPUT
if [[ "$REF" == "refs/tags/v"* ]]; then
tag=$(git describe --tags $(git rev-list --tags --max-count=1))
version=${tag:1}
package_version="$(echo "$version" | awk -F 'v' '{print $1}')"
else
date=$(git log -1 --format="%cd" --date=short | sed s/-//g)
count=$(git rev-list --count HEAD)
commit=$(git rev-parse --short HEAD)
version="unstable-$date.r${count}.$commit"
package_version="$date.r${count}.$commit"
fi
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$package_version" >> $GITHUB_OUTPUT
echo "PACKAGE_VERSION=$package_version" >> $GITHUB_ENV
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: v2raya_${{ steps.get_filename.outputs.BUILD_NAME }}_${{ steps.prep.outputs.VERSION }}
path: build/
- name: Download x64 Linux Build
uses: actions/download-artifact@v3
with:
name: v2raya_linux_x64_${{ steps.prep.outputs.VERSION }}
path: test/
- name: Show Artifacts
run: |
ls -l build/
- name: Build Packages
run: |
sudo gem install fpm -v 1.15.1
sudo apt-get install -y libarchive-tools rpm tar unzip
sudo chmod 755 ./test/v2raya_linux_x64_$VERSION
./test/v2raya_linux_x64_$VERSION --report config | sed '1,6d' | fold -s -w 78 | sed -E 's/^([^#].+)/# \1/' >> install/universal/v2raya.default
if [ -n "$(echo $GOARCH | grep mips)" ]; then
packages="deb rpm"
else
packages="deb rpm pacman"
fi
sudo chmod 755 ./build/v2raya_${{ steps.get_filename.outputs.BUILD_NAME }}_${{ steps.prep.outputs.VERSION }}
for package_manager in $packages; do
if [ "$package_manager" == 'pacman' ];then
if [ "$GOARCH" == 'arm' ] && [ "$GOARM" == '7' ];then
package_arch='arm7hf'
elif [ "$GOARCH" == 'arm64' ];then
package_arch='aarch64'
else
package_arch="$GOARCH"
fi
elif [ "$package_manager" == 'rpm' ];then
if [ "$GOARCH" == 'arm' ] && [ "$GOARM" == '7' ];then
package_arch='armhfp'
elif [ "$GOARCH" == 'arm64' ];then
package_arch='aarch64'
else
package_arch="$GOARCH"
fi
elif [ "$package_manager" == 'deb' ];then
if [ "$GOARCH" == 'arm' ] && [ "$GOARM" == '7' ];then
package_arch='armhf'
elif [ "$GOARCH" == '386' ];then
package_arch='i386'
elif [ "$GOARCH" == 'mipsle' ];then
package_arch='mips32le'
else
package_arch="$GOARCH"
fi
fi
fpm -s dir -t "$package_manager" -a $package_arch --version "${{ steps.prep.outputs.PACKAGE_VERSION }}" \
--url 'https://github.com/v2rayA/v2rayA' --description "$DESC" \
--maintainer "[email protected]" --name v2raya --license 'AGPL' \
--package installer_linux_$GOARCH$GOAMD64$GOARM_${{ steps.prep.outputs.VERSION }}.$package_manager \
--after-install ./install/universal/after_install.sh \
--after-upgrade ./install/universal/after_upgrade.sh \
./build/v2raya_${{ steps.get_filename.outputs.BUILD_NAME }}_${{ steps.prep.outputs.VERSION }}=/usr/bin/v2raya \
./install/universal/v2raya.service=/usr/lib/systemd/system/v2raya.service \
./install/universal/v2raya-lite.service=/usr/lib/systemd/user/v2raya-lite.service \
./install/universal/v2raya.png=/usr/share/icons/hicolor/512x512/apps/v2raya.png \
./install/universal/v2raya.desktop=/usr/share/applications/v2raya.desktop \
./install/universal/v2raya.default=/etc/default/v2raya
done
mkdir fpm_packages
[ -f installer_linux_$GOARCH$GOAMD64$GOARM_${{ steps.prep.outputs.VERSION }}.pacman ] && \
mv installer_linux_$GOARCH$GOAMD64$GOARM_${{ steps.prep.outputs.VERSION }}.pacman \
fpm_packages/installer_archlinux_${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ steps.prep.outputs.VERSION }}.pkg.tar.zst
mv installer_linux_$GOARCH$GOAMD64$GOARM_${{ steps.prep.outputs.VERSION }}.rpm \
fpm_packages/installer_redhat_${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ steps.prep.outputs.VERSION }}.rpm
mv installer_linux_$GOARCH$GOAMD64$GOARM_${{ steps.prep.outputs.VERSION }}.deb \
fpm_packages/installer_debian_${{ steps.get_filename.outputs.FRIENDLY_ARCH }}_${{ steps.prep.outputs.VERSION }}.deb
- name: Upload Artifact
uses: nanoufo/[email protected]
with:
path: |
fpm_packages/*
GitHub_Release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: windows-latest
needs: [Build_v2rayA_Binaries, Build_Windows_Installers, Build_Linux_Packages]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check Version
id: prep
env:
REF: ${{ github.ref }}
shell: bash
run: |
echo "P_DIR=$(pwd)" >> $GITHUB_OUTPUT
tag=$(git describe --tags $(git rev-list --tags --max-count=1))
version=${tag:1}
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_ENV
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: builds/
- name: Move Files to Release Directory
shell: bash
run: |
mkdir -p release
for file in $(ls builds | grep -E "^installer|^v2raya"); do
mv builds/$file/$file release/
done
mv builds/web.tar.gz/web.tar.gz release/
for file in $(ls release); do
sha256sum release/$file | awk '{print $1}' > release/$file.sha256.txt
done
ls -l release/
- name: Compress Web Files
shell: pwsh
run: |
Compress-Archive -Path ./builds/web/* -DestinationPath ./web.zip
((Get-FileHash ./web.zip).hash).ToLower() > web.zip.sha256.txt
Move-Item ./web.zip ./release/web.zip
Move-Item ./web.zip.sha256.txt ./release/web.zip.sha256.txt
- name: Upload Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.prep.outputs.VERSION }}
files: |
release/*
# - name: Refresh Cloudflare Cache
# env:
# CF_AUTH_EMAIL: ${{ secrets.CF_AUTH_EMAIL }}
# CF_PARGE_CACHE_AUTH_KEY: ${{ secrets.CF_PARGE_CACHE_AUTH_KEY }}
# CF_ZONE: ${{ secrets.CF_ZONE }}
# shell: bash
# run: |
# curl -X POST "https://api.cloudflare.com/client/v4/zones/$CF_ZONE/purge_cache" \
# -H "X-Auth-Email: $CF_AUTH_EMAIL" \
# -H "Authorization: Bearer $CF_PARGE_CACHE_AUTH_KEY" \
# -H "Content-Type: application/json" \
# --data '{"purge_everything":true}'
# - name: Submit to Microsoft winget
# shell: pwsh
# run: |
# iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
# Start-Sleep -Seconds 30 #Make sure GitHub releases are online
# $Installer_x64_url = "https://github.com/v2rayA/v2rayA/releases/download/v${{ steps.prep.outputs.VERSION }}/installer_windows_inno_x64_${{ steps.prep.outputs.VERSION }}.exe"
# $Installer_ARM64_url = "https://github.com/v2rayA/v2rayA/releases/download/v${{ steps.prep.outputs.VERSION }}/installer_windows_inno_arm64_${{ steps.prep.outputs.VERSION }}.exe"
# ./wingetcreate.exe update v2rayA.v2rayA --urls $Installer_x64_url $Installer_ARM64_url --version ${{ steps.prep.outputs.VERSION }} --token ${{ secrets.HOMEBREW_V2RAYA_TOKEN }} --submit
Build_v2ray_Debian_Packages:
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Install Tools
run: |
sudo apt-get update -y && sudo apt-get install -y wget curl unzip
sudo gem install fpm -v 1.15.1
- name: Check Version
run: |
v2ray_temp_file="./v2ray.version.temp"
if ! curl -s -I "https://github.com/v2fly/v2ray-core/releases/latest" > "$v2ray_temp_file"; then
echo "${RED}Error: Cannot get latest version of v2ray!${RESET}"
exit 1
fi
v2ray_version=$(grep -i ^location: "$v2ray_temp_file" | awk '{print $2}' | tr -d '\r' | awk -F 'tag/' '{print $2}')
rm -f "$v2ray_temp_file"
xray_temp_file="./xray.version.temp"
if ! curl -s -I "https://github.com/XTLS/Xray-core/releases/latest" > "$xray_temp_file"; then
echo "${RED}Error: Cannot get latest version of xray!${RESET}"
exit 1
fi
xray_version=$(grep -i ^location: "$xray_temp_file" | awk '{print $2}' | tr -d '\r' | awk -F 'tag/' '{print $2}')
rm -f "$xray_temp_file"
echo "V2RAY_VERSION=$v2ray_version" >> $GITHUB_OUTPUT
echo "XRAY_VERSION=$xray_version" >> $GITHUB_OUTPUT
echo "V2RAY_VERSION=$v2ray_version" >> $GITHUB_ENV
echo "XRAY_VERSION=$xray_version" >> $GITHUB_ENV
- name: Download v2ray and Xray
run: |
mkdir xray_unzipped
mkdir v2ray_unzipped
for arch in 64 32 arm64-v8a arm32-v7a mips32 mips32le mips64 mips64le riscv64; do
wget -q https://github.com/v2fly/v2ray-core/releases/download/$V2RAY_VERSION/v2ray-linux-$arch.zip
unzip -q v2ray-linux-$arch.zip -d v2ray_unzipped/v2ray-linux-$arch
wget -q https://github.com/XTLS/xray-core/releases/download/$XRAY_VERSION/Xray-linux-$arch.zip
unzip -q Xray-linux-$arch.zip -d xray_unzipped/xray-linux-$arch
done
- name: Build v2ray Packages
run: |
mkdir v2ray_packages
package_version="$(echo "$V2RAY_VERSION" | sed 's/v//g')" # Remove the leading 'v' in version number
for arch in amd64 i386 arm64 armhf mips mips32le mips64 mips64le riscv64; do
case $arch in
amd64)
source_dir="v2ray_unzipped/v2ray-linux-64"
;;
i386)
source_dir="v2ray_unzipped/v2ray-linux-32"
;;
arm64)
source_dir="v2ray_unzipped/v2ray-linux-arm64-v8a"
;;
armhf)
source_dir="v2ray_unzipped/v2ray-linux-arm32-v7a"
;;
mips)
source_dir="v2ray_unzipped/v2ray-linux-mips32"
;;
mips32le)
source_dir="v2ray_unzipped/v2ray-linux-mips32le"
;;
mips64)
source_dir="v2ray_unzipped/v2ray-linux-mips64"
;;
mips64le)
source_dir="v2ray_unzipped/v2ray-linux-mips64le"
;;
riscv64)
source_dir="v2ray_unzipped/v2ray-linux-riscv64"
;;
esac
echo 'systemctl daemon-reload
if [ "$(systemctl is-active v2ray)" = "active" ]; then
systemctl restart v2ray
fi' > $source_dir/postinst
echo "systemctl daemon-reload" >> $source_dir/post-remove
sed -i 's|usr/local/bin/v2ray|usr/bin/v2ray|g' $source_dir/systemd/system/v2ray.service
sed -i 's|usr/local/bin/v2ray|usr/bin/v2ray|g' $source_dir/systemd/system/[email protected]
sed -i 's|usr/local/etc/v2ray|etc/v2ray|g' $source_dir/systemd/system/v2ray.service
sed -i 's|usr/local/etc/v2ray|etc/v2ray|g' $source_dir/systemd/system/[email protected]
fpm -s dir -t deb -a $arch --version $package_version \
--url 'https://v2fly.org/' --description 'A platform for building proxies to bypass network restrictions' \
--maintainer "[email protected]" --name v2ray --license 'MIT' \
--package ./v2ray_packages/v2ray_"$arch"_"$package_version".deb \
--after-install $source_dir/postinst \
--after-remove $source_dir/post-remove \
$source_dir/v2ray=/usr/bin/v2ray \
$source_dir/systemd/system/v2ray.service=/usr/lib/systemd/system/v2ray.service \
$source_dir/systemd/system/[email protected]=/usr/lib/systemd/system/[email protected] \
$source_dir/geoip.dat=/usr/share/v2ray/geoip.dat \
$source_dir/geoip-only-cn-private.dat=/usr/share/v2ray/geoip-only-cn-private.dat \
$source_dir/geosite.dat=/usr/share/v2ray/geosite.dat
done
- name: Build Xray Packages
run: |
mkdir xray_packages
package_version="$(echo "$XRAY_VERSION" | sed 's/v//g')" # Remove the leading 'v' in version number
for arch in amd64 i386 arm64 armhf mips mips32le mips64 mips64le riscv64; do
case $arch in
amd64)
source_dir="xray_unzipped/xray-linux-64"
;;
i386)
source_dir="xray_unzipped/xray-linux-32"
;;
arm64)
source_dir="xray_unzipped/xray-linux-arm64-v8a"
;;
armhf)
source_dir="xray_unzipped/xray-linux-arm32-v7a"
;;
mips)
source_dir="xray_unzipped/xray-linux-mips32"
;;
mips32le)
source_dir="xray_unzipped/xray-linux-mips32le"
;;
mips64)
source_dir="xray_unzipped/xray-linux-mips64"
;;
mips64le)
source_dir="xray_unzipped/xray-linux-mips64le"
;;
riscv64)
source_dir="xray_unzipped/xray-linux-riscv64"
;;
esac
fpm -s dir -t deb -a $arch --version $package_version \
--url 'https://xtls.github.io/' --description 'Xray, Penetrates Everything. Also the best v2ray-core, with XTLS support. Fully compatible configuration' \
--maintainer "[email protected]" --name xray --license 'MPL-2.0' \
--package ./xray_packages/xray_"$arch"_"$package_version".deb \
$source_dir/xray=/usr/bin/xray \
$source_dir/geoip.dat=/usr/share/xray/geoip.dat \
$source_dir/geosite.dat=/usr/share/xray/geosite.dat
done
- name: Upload Artifact
uses: nanoufo/[email protected]
with:
path: |
v2ray_packages/*
xray_packages/*
Build_APT_Repository_and_AUR:
runs-on: ubuntu-22.04
needs: [Build_v2rayA_Binaries, Build_Linux_Packages, Build_v2ray_Debian_Packages]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check Version
id: prep
run: |
echo "P_DIR=$(pwd)" >> $GITHUB_OUTPUT
tag=$(git describe --tags $(git rev-list --tags --max-count=1))
version=${tag:1}
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_ENV
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: builds/
- name: Prepare Builds
run: |
sudo apt install -y lintian reprepro gnupg gnupg2 expect >> /dev/null
mkdir -p install/debian
for deb_package in $(ls builds | grep .deb); do
mv builds/"$deb_package"/"$deb_package" ./"$deb_package"
done
for v2raya_bin in $(ls builds | grep -E "^v2raya_linux"); do
mv builds/"$v2raya_bin"/"$v2raya_bin" ./"$v2raya_bin"
done
mv builds/web.tar.gz/web.tar.gz ./web.tar.gz
v2ray_version="$(ls | grep "^v2ray_" | grep amd64 | awk -F '_' '{print $3}' | sed 's/.deb//')"
xray_version="$(ls | grep "^xray_" | grep amd64 | awk -F '_' '{print $3}' | sed 's/.deb//')"
echo "V2RAY_VERSION=$v2ray_version" >> $GITHUB_OUTPUT
echo "XRAY_VERSION=$xray_version" >> $GITHUB_OUTPUT
echo "V2RAY_VERSION=$v2ray_version" >> $GITHUB_ENV
echo "XRAY_VERSION=$xray_version" >> $GITHUB_ENV
- name: Import GPG key
id: import_gpg
uses: crazy-max/[email protected]
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.SIGNING_PASSWORD }}
- name: Generate APT Repository
env:
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
run: |
mkdir -p apt/incoming && cp -r install/debian/key install/debian/conf apt/
install/tool/reprepro_expect --ask-passphrase -Vb apt includedeb v2raya installer_debian_*_$VERSION.deb xray_*_$XRAY_VERSION.deb v2ray_*_$V2RAY_VERSION.deb
install/tool/reprepro_expect --ask-passphrase -Vb apt export
mkdir apt/static/
cp v2raya_*_*_${{ steps.prep.outputs.VERSION }}* apt/static/
cp web.tar.gz apt/static/web_$VERSION.tar.gz
echo "apt.v2raya.org" > apt/CNAME
- name: Deploy APT Repository
uses: crazy-max/[email protected]
with:
repo: v2rayA/v2raya-apt
target_branch: master
build_dir: apt
env:
GH_PAT: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: AUR Release
env:
P_DIR: ${{ steps.prep.outputs.P_DIR }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
run: |
eval $(ssh-agent)
echo "$SSH_PRIVATE_KEY" > ./key
chmod 0600 ./key
./install/tool/ssh-add_expect ./key
bash install/aur/deploy.sh
Release_to_Homebrew:
runs-on: ubuntu-22.04
needs: [Build_v2rayA_Binaries]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check Version
id: prep
run: |
echo "P_DIR=$(pwd)" >> $GITHUB_OUTPUT
tag=$(git describe --tags $(git rev-list --tags --max-count=1))
version=${tag:1}
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_ENV
- name: Download Artifact Linux x64
uses: actions/download-artifact@v3
with:
name: v2raya_linux_x64_${{ steps.prep.outputs.VERSION }}
path: Downloads
- name: Download Artifact macOS x64
uses: actions/download-artifact@v3
with:
name: v2raya_darwin_x64_${{ steps.prep.outputs.VERSION }}
path: Downloads
- name: Download Artifact macOS arm64
uses: actions/download-artifact@v3
with:
name: v2raya_darwin_arm64_${{ steps.prep.outputs.VERSION }}
path: Downloads
- name: Compress to Zip Files
run: |
mkdir v2raya-x86_64-linux; cp Downloads/v2raya_linux_x64_${{ steps.prep.outputs.VERSION }} ./v2raya-x86_64-linux/v2raya
mkdir v2raya-x86_64-macos; cp Downloads/v2raya_darwin_x64_${{ steps.prep.outputs.VERSION }} ./v2raya-x86_64-macos/v2raya
mkdir v2raya-aarch64-macos; cp Downloads/v2raya_darwin_arm64_${{ steps.prep.outputs.VERSION }} ./v2raya-aarch64-macos/v2raya
zip -r9 v2raya-x86_64-linux.zip ./v2raya-x86_64-linux/*
zip -r9 v2raya-x86_64-macos.zip ./v2raya-x86_64-macos/*
zip -r9 v2raya-aarch64-macos.zip ./v2raya-aarch64-macos/*
for file in $(ls v2raya-*.zip); do
sha256sum $file > $file.sha256.txt
done
- name: Upload to Homebrew Tap
env:
GH_TOKEN: ${{ secrets.HOMEBREW_V2RAYA_TOKEN }}
run: |
tag_version=$(echo $VERSION | sed 's/v//g')
gh release create $tag_version --repo v2rayA/homebrew-v2raya \
--title "Releases $VERSION" --generate-notes
gh release upload $tag_version --repo v2rayA/homebrew-v2raya \
v2raya-x86_64-linux.zip v2raya-x86_64-linux.zip.sha256.txt \
v2raya-x86_64-macos.zip v2raya-x86_64-macos.zip.sha256.txt \
v2raya-aarch64-macos.zip v2raya-aarch64-macos.zip.sha256.txt
Release_to_Docker:
runs-on: ubuntu-22.04
needs: [GitHub_Release]
if: startsWith(github.ref, 'refs/tags/v')
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check Version
id: prep
run: |
tag=$(git describe --tags $(git rev-list --tags --max-count=1))
version=${tag:1}
echo "VERSION=$version" >> $GITHUB_OUTPUT
echo "VERSION=$version" >> $GITHUB_ENV
TAG=$(echo $GITHUB_REF | cut -d / -f 3)
IMAGE="mzz2017/v2raya"
echo image=${IMAGE} >> $GITHUB_OUTPUT
echo tag=${TAG} >> $GITHUB_OUTPUT
echo tag=${TAG} > ./version
- name: Set up QEMU
uses: docker/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
# - name: Login to DockerHub
# uses: docker/[email protected]
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/[email protected]
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: install/docker/Dockerfile.Action
platforms: linux/arm,linux/arm64,linux/amd64
push: true
tags: |
${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.tag }}
${{ steps.prep.outputs.image }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max