-
Notifications
You must be signed in to change notification settings - Fork 4
624 lines (533 loc) 路 23.1 KB
/
Copy pathrelease.yml
File metadata and controls
624 lines (533 loc) 路 23.1 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
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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
env:
SING_BOX_VERSION: "1.13.13"
jobs:
build:
name: Build ${{ matrix.asset }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
target: x86_64-pc-windows-msvc
binary: v2raydar.exe
asset: v2raydar-windows-x86_64.exe
embedded_asset: v2raydar-windows-x86_64_with_singbox.zip
embedded_format: zip
embedded_binary: v2raydar.exe
sing_box_platform: windows
sing_box_arch: amd64
sing_box_binary: sing-box.exe
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
binary: v2raydar
asset: v2raydar-linux-x86_64
embedded_asset: v2raydar-linux-x86_64_with_singbox.tar.gz
embedded_format: tar.gz
embedded_binary: v2raydar
sing_box_platform: linux
sing_box_arch: amd64
sing_box_binary: sing-box
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Cargo build state
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target/${{ matrix.target }}
key: cargo-build-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-build-${{ runner.os }}-${{ matrix.target }}-
- name: Install Rust target
shell: bash
run: |
rustup default stable
rustup target add "${{ matrix.target }}"
- name: Build release binary
run: cargo build --release --locked --target "${{ matrix.target }}"
- name: Stage executable
shell: pwsh
run: |
New-Item -ItemType Directory -Force dist | Out-Null
$source = Join-Path "target/${{ matrix.target }}/release" "${{ matrix.binary }}"
$destination = Join-Path "dist" "${{ matrix.asset }}"
Copy-Item -LiteralPath $source -Destination $destination
- name: Upload executable artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset }}
path: dist/${{ matrix.asset }}
if-no-files-found: error
- name: Stage embedded sing-box package
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$ErrorActionPreference = "Stop"
$headers = @{ "User-Agent" = "github-actions" }
# Inject the token into the headers if it exists
if ([bool]$env:GITHUB_TOKEN) {
$headers["Authorization"] = "Bearer $($env:GITHUB_TOKEN)"
}
$version = "${{ env.SING_BOX_VERSION }}"
$release = Invoke-RestMethod -Headers $headers -Uri "https://api.github.com/repos/SagerNet/sing-box/releases/tags/v$version"
function Test-NameToken([string]$Name, [string]$Token) {
return $Name -match ('(^|[-_.])' + [regex]::Escape($Token) + '($|[-_.])')
}
$asset = $release.assets |
Where-Object {
$name = $_.name.ToLowerInvariant()
$name -like "*${{ matrix.sing_box_platform }}*" -and
(Test-NameToken $name "${{ matrix.sing_box_arch }}") -and
($name.EndsWith(".zip") -or $name.EndsWith(".tar.gz") -or $name.EndsWith(".tgz"))
} |
Select-Object -First 1
if (-not $asset) {
throw "No sing-box v$version asset found for ${{ matrix.sing_box_platform }}-${{ matrix.sing_box_arch }}"
}
$download = Join-Path "dist" $asset.name
Invoke-WebRequest -Headers $headers -Uri $asset.browser_download_url -OutFile $download
$extractRoot = Join-Path "dist" "sing-box-$version-${{ matrix.sing_box_platform }}-${{ matrix.sing_box_arch }}"
New-Item -ItemType Directory -Force $extractRoot | Out-Null
if ($asset.name.ToLowerInvariant().EndsWith(".zip")) {
Expand-Archive -LiteralPath $download -DestinationPath $extractRoot -Force
} else {
tar -xf $download -C $extractRoot
}
$singBox = Get-ChildItem -LiteralPath $extractRoot -Recurse -File -Filter "${{ matrix.sing_box_binary }}" |
Select-Object -First 1
if (-not $singBox) {
throw "sing-box executable was not found after extracting $($asset.name)"
}
& $singBox.FullName version
$packageRoot = Join-Path "dist" "package-${{ matrix.embedded_asset }}"
New-Item -ItemType Directory -Force $packageRoot | Out-Null
Copy-Item -LiteralPath (Join-Path "dist" "${{ matrix.asset }}") -Destination (Join-Path $packageRoot "${{ matrix.embedded_binary }}")
Copy-Item -LiteralPath $singBox.FullName -Destination (Join-Path $packageRoot "${{ matrix.sing_box_binary }}")
if ("${{ runner.os }}" -ne "Windows") {
chmod +x (Join-Path $packageRoot "${{ matrix.embedded_binary }}")
chmod +x (Join-Path $packageRoot "${{ matrix.sing_box_binary }}")
}
if ("${{ matrix.embedded_format }}" -eq "zip") {
Compress-Archive -Path (Join-Path $packageRoot "*") -DestinationPath (Join-Path "dist" "${{ matrix.embedded_asset }}") -Force
} else {
tar -C $packageRoot -czf (Join-Path "dist" "${{ matrix.embedded_asset }}") .
}
- name: Upload embedded sing-box artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.embedded_asset }}
path: dist/${{ matrix.embedded_asset }}
if-no-files-found: error
build-macos:
name: Build v2raydar-macos-universal.app.zip
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Cargo build state
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target/x86_64-apple-darwin
target/aarch64-apple-darwin
key: cargo-build-${{ runner.os }}-macos-universal-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-build-${{ runner.os }}-macos-universal-
- name: Install Rust targets
shell: bash
run: |
rustup default stable
rustup target add x86_64-apple-darwin aarch64-apple-darwin
- name: Build release binaries
shell: bash
run: |
cargo build --release --locked --target x86_64-apple-darwin
cargo build --release --locked --target aarch64-apple-darwin
- name: Stage universal app bundle
shell: bash
run: |
set -euo pipefail
asset="v2raydar-macos-universal.app.zip"
app="dist/V2RayDAR.app"
version="$(awk -F '"' '/^version = / { print $2; exit }' Cargo.toml)"
mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
lipo -create \
-output "$app/Contents/MacOS/v2raydar-bin" \
"target/x86_64-apple-darwin/release/v2raydar" \
"target/aarch64-apple-darwin/release/v2raydar"
chmod +x "$app/Contents/MacOS/v2raydar-bin"
lipo -info "$app/Contents/MacOS/v2raydar-bin"
cat > "$app/Contents/MacOS/V2RayDAR" <<'EOF'
#!/bin/sh
set -eu
dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
app="$dir/v2raydar-bin"
if [ -t 1 ]; then
exec "$app" "$@"
fi
APP_PATH="$app" osascript <<'APPLESCRIPT'
set appPath to system attribute "APP_PATH"
tell application "Terminal"
activate
do script quoted form of appPath
end tell
APPLESCRIPT
EOF
chmod +x "$app/Contents/MacOS/V2RayDAR"
cat > "$app/Contents/Info.plist" <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>V2RayDAR</string>
<key>CFBundleIconFile</key>
<string>V2RayDAR</string>
<key>CFBundleIdentifier</key>
<string>app.v2raydar.V2RayDAR</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>V2RayDAR</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${version}</string>
<key>CFBundleVersion</key>
<string>${GITHUB_RUN_NUMBER}</string>
<key>LSMinimumSystemVersion</key>
<string>10.13</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
EOF
iconset="dist/V2RayDAR.iconset"
mkdir -p "$iconset"
sips -z 16 16 "assets/V2RayDAR_logo_v1.png" --out "$iconset/icon_16x16.png" >/dev/null
sips -z 32 32 "assets/V2RayDAR_logo_v1.png" --out "$iconset/icon_16x16@2x.png" >/dev/null
sips -z 32 32 "assets/V2RayDAR_logo_v1.png" --out "$iconset/icon_32x32.png" >/dev/null
sips -z 64 64 "assets/V2RayDAR_logo_v1.png" --out "$iconset/icon_32x32@2x.png" >/dev/null
sips -z 128 128 "assets/V2RayDAR_logo_v1.png" --out "$iconset/icon_128x128.png" >/dev/null
sips -z 256 256 "assets/V2RayDAR_logo_v1.png" --out "$iconset/icon_128x128@2x.png" >/dev/null
sips -z 256 256 "assets/V2RayDAR_logo_v1.png" --out "$iconset/icon_256x256.png" >/dev/null
sips -z 512 512 "assets/V2RayDAR_logo_v1.png" --out "$iconset/icon_256x256@2x.png" >/dev/null
sips -z 512 512 "assets/V2RayDAR_logo_v1.png" --out "$iconset/icon_512x512.png" >/dev/null
sips -z 1024 1024 "assets/V2RayDAR_logo_v1.png" --out "$iconset/icon_512x512@2x.png" >/dev/null
iconutil -c icns "$iconset" -o "$app/Contents/Resources/V2RayDAR.icns"
ditto -c -k --sequesterRsrc --keepParent "$app" "dist/$asset"
- name: Upload app artifact
uses: actions/upload-artifact@v4
with:
name: v2raydar-macos-universal.app.zip
path: dist/v2raydar-macos-universal.app.zip
if-no-files-found: error
- name: Stage embedded sing-box app bundle
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
version="${SING_BOX_VERSION}"
embedded_asset="v2raydar-macos-universal_with_singbox.zip"
work="dist/sing-box-${version}-darwin"
mkdir -p "$work"
python3 <<'PY'
import json
import os
import re
import urllib.request
version = os.environ["SING_BOX_VERSION"]
github_token = os.environ.get("GITHUB_TOKEN")
work = os.path.join("dist", f"sing-box-{version}-darwin")
url = f"https://api.github.com/repos/SagerNet/sing-box/releases/tags/v{version}"
headers = {"User-Agent": "github-actions"}
# Inject the token into the headers if it exists
if github_token:
headers["Authorization"] = f"Bearer {github_token}"
req = urllib.request.Request(url, headers=headers)
release = json.load(urllib.request.urlopen(req))
def token(name, value):
return re.search(r"(^|[-_.])" + re.escape(value) + r"($|[-_.])", name) is not None
for arch in ("amd64", "arm64"):
for asset in release.get("assets", []):
name = asset["name"].lower()
if "darwin" in name and token(name, arch) and name.endswith((".tar.gz", ".tgz", ".zip")):
target = os.path.join(work, asset["name"])
# Create a request object for the download to pass headers here too
download_req = urllib.request.Request(asset["browser_download_url"], headers=headers)
with urllib.request.urlopen(download_req) as response, open(target, 'wb') as out_file:
out_file.write(response.read())
break
else:
raise SystemExit(f"No sing-box v{version} darwin-{arch} asset found")
PY
for archive in "$work"/*; do
mkdir -p "$work/extract/$(basename "$archive")"
case "$archive" in
*.zip) unzip -q "$archive" -d "$work/extract/$(basename "$archive")" ;;
*) tar -xf "$archive" -C "$work/extract/$(basename "$archive")" ;;
esac
done
amd64_bin="$(find "$work/extract" -path '*darwin-amd64*' -type f -name sing-box | head -n 1)"
arm64_bin="$(find "$work/extract" -path '*darwin-arm64*' -type f -name sing-box | head -n 1)"
test -n "$amd64_bin"
test -n "$arm64_bin"
lipo -create -output "dist/V2RayDAR.app/Contents/MacOS/sing-box" "$amd64_bin" "$arm64_bin"
chmod +x "dist/V2RayDAR.app/Contents/MacOS/sing-box"
"dist/V2RayDAR.app/Contents/MacOS/sing-box" version
ditto -c -k --sequesterRsrc --keepParent "dist/V2RayDAR.app" "dist/$embedded_asset"
- name: Upload embedded sing-box app artifact
uses: actions/upload-artifact@v4
with:
name: v2raydar-macos-universal_with_singbox.zip
path: dist/v2raydar-macos-universal_with_singbox.zip
if-no-files-found: error
build-termux:
name: Build ${{ matrix.asset }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: aarch64-linux-android
clang_prefix: aarch64-linux-android
asset: v2raydar-termux-aarch64.tar.gz
package_dir: v2raydar-termux-aarch64
label: aarch64
- target: x86_64-linux-android
clang_prefix: x86_64-linux-android
asset: v2raydar-termux-x86_64.tar.gz
package_dir: v2raydar-termux-x86_64
label: x86_64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Cargo build state
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target/${{ matrix.target }}
key: cargo-build-${{ runner.os }}-${{ matrix.target }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-build-${{ runner.os }}-${{ matrix.target }}-
- name: Install Rust target
shell: bash
run: |
rustup default stable
rustup target add "${{ matrix.target }}"
- name: Build release binary
shell: bash
env:
API_LEVEL: "24"
run: |
set -euo pipefail
ndk="${ANDROID_NDK_HOME:-${ANDROID_NDK_LATEST_HOME:-}}"
if [ -z "$ndk" ]; then
echo "ANDROID_NDK_HOME or ANDROID_NDK_LATEST_HOME is required" >&2
exit 1
fi
linker="${ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/${{ matrix.clang_prefix }}${API_LEVEL}-clang"
ar="${ndk}/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar"
test -x "$linker"
test -x "$ar"
linker_var="CARGO_TARGET_$(echo "${{ matrix.target }}" | tr '[:lower:]-' '[:upper:]_')_LINKER"
cc_var="CC_$(echo "${{ matrix.target }}" | tr '-' '_')"
ar_var="AR_$(echo "${{ matrix.target }}" | tr '-' '_')"
export "$linker_var=$linker"
export "$cc_var=$linker"
export "$ar_var=$ar"
cargo build --release --locked --target "${{ matrix.target }}"
- name: Stage Termux package
shell: bash
run: |
set -euo pipefail
asset="${{ matrix.asset }}"
package="dist/${{ matrix.package_dir }}"
mkdir -p "$package"
cp target/${{ matrix.target }}/release/v2raydar "$package/v2raydar"
chmod +x "$package/v2raydar"
# Bundle sing-box android binary from SagerNet releases
# Note: GitHub release assets use arm64/amd64, not aarch64/x86_64
case "${{ matrix.label }}" in
aarch64) _sb_arch="arm64" ;;
x86_64) _sb_arch="amd64" ;;
*) echo "unexpected label: ${{ matrix.label }}" >&2; exit 1 ;;
esac
_sb_url="https://github.com/SagerNet/sing-box/releases/download/v${SING_BOX_VERSION}/sing-box-${SING_BOX_VERSION}-android-${_sb_arch}.tar.gz"
if curl -fSL --progress-bar "$_sb_url" -o /tmp/sing-box-termux.tar.gz; then
_sb_tmp="$(mktemp -d)"
tar xzf /tmp/sing-box-termux.tar.gz -C "$_sb_tmp" --strip-components=1
_sb_bin="$(find "$_sb_tmp" -name sing-box -type f | head -1)"
if [ -n "$_sb_bin" ]; then
cp "$_sb_bin" "$package/sing-box"
chmod +x "$package/sing-box"
echo "bundled sing-box ${SING_BOX_VERSION} for android-${_sb_arch}"
fi
rm -rf "$_sb_tmp"
fi
rm -f /tmp/sing-box-termux.tar.gz
cat > "$package/install-termux.sh" <<'INSTALLEOF'
#!/data/data/com.termux/files/usr/bin/bash
set -eu
cd "$(dirname "$0")"
SING_BOX_VERSION="1.13.13"
SING_BOX_GITHUB="https://github.com/SagerNet/sing-box/releases/download/v${SING_BOX_VERSION}"
info() { printf '\033[1;34m>\033[0m %s\n' "$*"; }
warn() { printf '\033[1;33m!\033[0m %s\n' "$*"; }
install_singbox() {
# 1) If bundled in the archive, use it directly
if [ -f "./sing-box" ]; then
install -Dm755 "./sing-box" "${PREFIX}/bin/sing-box"
info "sing-box installed from bundled binary"
return 0
fi
# 2) Try Termux package (pinned version)
if pkg install -y "sing-box=${SING_BOX_VERSION}" 2>/dev/null; then
info "sing-box installed via pkg (pinned)"
return 0
fi
# 3) Try Termux package (any version)
if pkg install -y sing-box 2>/dev/null; then
info "sing-box installed via pkg (latest available)"
return 0
fi
# 4) Download android binary from GitHub releases
_arch="$(uname -m)"
case "$_arch" in
aarch64) _sb_arch="arm64" ;;
x86_64) _sb_arch="amd64" ;;
*) warn "unsupported arch for sing-box: $_arch"; return 1 ;;
esac
_url="${SING_BOX_GITHUB}/sing-box-${SING_BOX_VERSION}-android-${_sb_arch}.tar.gz"
info "downloading sing-box ${SING_BOX_VERSION} (android-${_sb_arch}) from GitHub..."
if ! curl -fSL --progress-bar "$_url" -o /tmp/sing-box.tar.gz; then
warn "download failed: $_url"
warn "try manually: pkg install sing-box"
return 1
fi
_tmpdir="$(mktemp -d)"
tar xzf /tmp/sing-box.tar.gz -C "$_tmpdir" --strip-components=1
_bin="$(find "$_tmpdir" -name sing-box -type f | head -1)"
if [ -z "$_bin" ]; then
warn "sing-box binary not found in archive"
rm -rf "$_tmpdir" /tmp/sing-box.tar.gz
return 1
fi
install -Dm755 "$_bin" "${PREFIX}/bin/sing-box"
rm -rf "$_tmpdir" /tmp/sing-box.tar.gz
info "sing-box installed from GitHub releases"
return 0
}
install_singbox || warn "Failed to install sing-box. Install manually: pkg install sing-box"
install -Dm755 v2raydar "${PREFIX}/bin/v2raydar"
cat <<'MSG'
Installed V2RayDAR to $PREFIX/bin/v2raydar.
Run with: v2raydar --no-tui
MSG
INSTALLEOF
chmod +x "$package/install-termux.sh"
cat > "$package/README-termux.txt" <<EOF
V2RayDAR Termux ${{ matrix.label }} release
This package is built for ${{ matrix.label }} Android devices running Termux.
It includes sing-box. If the bundled version is missing, the installer will
try pkg or download from GitHub releases.
Quick install:
pkg update -y && pkg install -y curl tar
tar -xzf ${asset}
cd ${{ matrix.package_dir }}
./install-termux.sh
v2raydar --no-tui
EOF
tar -C dist -czf "dist/$asset" "${{ matrix.package_dir }}"
- name: Upload Termux artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset }}
path: dist/${{ matrix.asset }}
if-no-files-found: error
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Cargo test state
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: cargo-test-${{ runner.os }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
cargo-test-${{ runner.os }}-
- name: Install Rust
shell: bash
run: |
rustup default stable
rustup component add rustfmt clippy
- name: Format check
run: cargo fmt --check
- name: Clippy
run: cargo clippy --locked --all-targets --all-features -- -D warnings
- name: Tests
run: cargo test --locked
publish:
name: Publish GitHub release
needs: [build, build-macos, build-termux, test]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.ref_name }}
REPOSITORY: ${{ github.repository }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download executable artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Generate SHA-256 checksums
shell: pwsh
run: |
$lines = Get-ChildItem -LiteralPath dist -File |
Sort-Object Name |
ForEach-Object {
$hash = (Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName).Hash.ToLowerInvariant()
"$hash $($_.Name)"
}
$lines | Set-Content -LiteralPath "dist/checksums.txt" -Encoding ascii
- name: Create or update release
shell: bash
run: |
git log -1 --format=%b > release-notes.txt
if gh release view "$TAG_NAME" --repo "$REPOSITORY" >/dev/null 2>&1; then
gh release edit "$TAG_NAME" --repo "$REPOSITORY" --notes-file release-notes.txt
gh release upload "$TAG_NAME" dist/* --clobber --repo "$REPOSITORY"
else
gh release create "$TAG_NAME" dist/* \
--repo "$REPOSITORY" \
--title "V2RayDAR $TAG_NAME" \
--notes-file release-notes.txt
fi