-
Notifications
You must be signed in to change notification settings - Fork 89
469 lines (398 loc) · 18.2 KB
/
DDTV_Test.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
name: DDTV5_Test
on:
push:
tags:
- "test*"
pull_request:
paths:
- 'Server/**'
- 'Client/**'
- 'Desktop/**'
- '!**/README.md'
workflow_dispatch:
jobs:
Server:
strategy:
matrix:
include:
- os: windows-latest
runtime: win-x64
- os: macOS-latest
runtime: osx-x64
- os: macOS-latest
runtime: osx-arm64
- os: ubuntu-latest
runtime: linux-x64
- os: ubuntu-latest
runtime: linux-arm
- os: ubuntu-latest
runtime: linux-arm64
- os: ubuntu-latest
runtime: linux-musl-x64
- os: ubuntu-latest
runtime: linux-musl-arm
- os: ubuntu-latest
runtime: linux-musl-arm64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use .NET 8.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Download and extract latest release (Linux or macOS)
if: runner.os != 'Windows'
run: |
mkdir -p Static
header="authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"
FILE_URL=$(curl -sH "$header" "https://api.github.com/repos/moehuhu/DDTV_GUI_React/releases/latest" \
| grep "browser_download_url.*ddtv-gui-react_v.*\.zip" \
| cut -d : -f 2,3 \
| tr -d \")
wget --header="$header" $FILE_URL -O ddtv-gui-react.zip
unzip ddtv-gui-react.zip -d Static
rm ddtv-gui-react.zip
shell: bash
- name: Download and extract latest release (Windows)
if: runner.os == 'Windows'
run: |
mkdir Static
$header = @{
Authorization = "Bearer ${{ secrets.GITHUB_TOKEN }}"
}
$url = Invoke-RestMethod -Uri https://api.github.com/repos/moehuhu/DDTV_GUI_React/releases/latest -Headers $header
$fileUrl = $url.assets | Where-Object { $_.name -match "ddtv-gui-react_v.*\.zip" } | Select-Object -ExpandProperty browser_download_url
Invoke-WebRequest -Uri $fileUrl -OutFile ddtv-gui-react.zip -Headers $header
Expand-Archive -Path ddtv-gui-react.zip -DestinationPath Static
Remove-Item -Path ddtv-gui-react.zip
shell: powershell
- name: Replace string with current date (Linux or macOS)
if: runner.os != 'Windows'
run: |
export TZ='Asia/Shanghai'
current_date=$(date +%Y-%m-%d)
current_time=$(date +%H:%M:%S)
combined_date_time="${current_date} ${current_time}"
echo ${combined_date_time}
sed -i.bak "s/CompilationTime/${combined_date_time}/g" Core/Init.cs
- name: Replace string with current date (Windows)
if: runner.os == 'Windows'
run: |
$beijingTime = [System.TimeZoneInfo]::ConvertTimeFromUtc((Get-Date).ToUniversalTime(), [System.TimeZoneInfo]::FindSystemTimeZoneById('China Standard Time'))
$current_date = $beijingTime.ToString("yyyy-MM-dd")
$current_time = $beijingTime.ToString("HH:mm:ss")
$combined_date_time = "$current_date $current_time"
Write-Output $combined_date_time
(Get-Content Core/Init.cs) -replace 'CompilationTime', $combined_date_time | Set-Content Core/Init.cs
- name: Replace VerString (Linux or macOS)
if: runner.os != 'Windows'
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
VERSION_NUMBER=$(echo $TAG_NAME | sed -n -E 's/^test([0-9]+\.[0-9]+\.[0-9]+)$/\1/p')
COMMIT_COUNT=$(git rev-list --count HEAD)
FINAL_VERSION="${VERSION_NUMBER}.${COMMIT_COUNT}"
echo ${FINAL_VERSION}
sed -i.bak "s/5.0.0.0/${FINAL_VERSION}/g" Core/Core.csproj
sed -i.bak "s/5.0.0.0/${FINAL_VERSION}/g" Server/Server.csproj
- name: Replace VerString (Windows)
if: runner.os == 'Windows'
run: |
$TAG_NAME = "${env:GITHUB_REF}".Replace("refs/tags/", "")
$VERSION_NUMBER = $TAG_NAME -replace ".*?(\d+\.\d+\.\d+).*", '$1'
$COMMIT_COUNT = git rev-list --count HEAD
$FINAL_VERSION = "$VERSION_NUMBER.$COMMIT_COUNT"
Write-Output $FINAL_VERSION
(Get-Content Core/Core.csproj) | Foreach-Object { $_ -replace "5.0.0.0", $FINAL_VERSION } | Set-Content Core/Core.csproj
(Get-Content Server/Server.csproj) | Foreach-Object { $_ -replace "5.0.0.0", $FINAL_VERSION } | Set-Content Server/Server.csproj
shell: pwsh
- name: Build Server
run: cd Server && dotnet publish --runtime ${{ matrix.runtime }} --configuration Release --self-contained true --output build_output
- name: Build Update
run: cd Update && dotnet publish --runtime ${{ matrix.runtime }} --configuration Release --self-contained true --output build_update_output
- name: Move Update (Linux or macOS)
if: runner.os != 'Windows'
run: |
source="Update/build_update_output/*"
destination="Server/build_output/Update"
mkdir -p $destination
mv $source $destination
- name: Move Update (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$source = "Update/build_update_output/*"
$destination = "Server/build_output/Update"
New-Item -ItemType Directory -Force -Path $destination
Move-Item -Path $source -Destination $destination
- name: Copy Static folder to build_output
run: cp -r Static Server/build_output/Static
- name: Copy ffmpeg.exe (Windows)
if: matrix.os == 'windows-latest'
run: |
mkdir Server/build_output/Plugins/ffmpeg
copy Server/Plugins/ffmpeg/ffmpeg.exe Server/build_output/Plugins/Plugins/ffmpeg/ffmpeg.exe
- name: Move all files to bin folder and create shortcut (Linux or macOS)
if: runner.os != 'Windows'
run: |
mkdir -p Server/build_output/bin
find Server/build_output -mindepth 1 -maxdepth 1 ! -name bin -exec mv {} Server/build_output/bin \;
echo "Creating shortcut for Server"
echo "#!/bin/bash" > Server/build_output/DDTV_Server.sh
echo "dir=\$(cd \"\$(dirname \"\$0\")\"; pwd)" >> Server/build_output/DDTV_Server.sh
echo "\$dir/bin/Server" >> Server/build_output/DDTV_Server.sh
chmod +x Server/build_output/DDTV_Server.sh
- name: Move all files to bin folder and create shortcut (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Get-ChildItem -Path "Server/build_output" | Move-Item -Destination "Server/build_output/bin"
$bat_file_path = "Server/build_output/启动DDTV_Server.bat"
$command = @"
setlocal EnableDelayedExpansion
set "abs_path=%~dp0"
cd %abs_path%bin
start Server.exe
"@
Set-Content -Path $bat_file_path -Value $command
- name: Add VersionFile (Linux or macOS)
if: runner.os != 'Windows'
run: |
echo "type=DDTV-Server-${{ matrix.os }}-${{ matrix.runtime }}" > Server/build_output/bin/ver.ini
echo "ver=${{ github.ref_name }}" >> Server/build_output/bin/ver.ini
- name: Add VersionFile (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$bat_file_path = "Server/build_output/bin/ver.ini"
$command = @"
type=DDTV-Server-${{ matrix.os }}-${{ matrix.runtime }}
ver=${{ github.ref_name }}
"@
Set-Content -Path $bat_file_path -Value $command
- name: List all files (Linux or macOS)
if: runner.os != 'Windows'
run: |
echo "Absolute paths:"
find "$(pwd)/Server/build_output" -type f
echo "Relative paths:"
find Server/build_output -type f
shell: bash
- name: List all files (Windows)
if: runner.os == 'Windows'
run: |
echo "Absolute paths:"
Get-ChildItem -Path "$(Resolve-Path Server/build_output)" -File -Recurse | ForEach-Object FullName
echo "Relative paths:"
Get-ChildItem -Path "Server/build_output" -File -Recurse | ForEach-Object Name
shell: powershell
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: DDTV-Server-${{ matrix.os }}-${{ matrix.runtime }}
path: Server/build_output
Desktop:
strategy:
matrix:
include:
- os: windows-latest
runtime: win-x64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use .NET 8.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Download and extract latest release (Windows)
if: runner.os == 'Windows'
run: |
mkdir Static
$header = @{
Authorization = "Bearer ${{ secrets.GITHUB_TOKEN }}"
}
$url = Invoke-RestMethod -Uri https://api.github.com/repos/moehuhu/DDTV_GUI_React/releases/latest -Headers $header
$fileUrl = $url.assets | Where-Object { $_.name -match "ddtv-gui-react_v.*\.zip" } | Select-Object -ExpandProperty browser_download_url
Invoke-WebRequest -Uri $fileUrl -OutFile ddtv-gui-react.zip -Headers $header
Expand-Archive -Path ddtv-gui-react.zip -DestinationPath Static
Remove-Item -Path ddtv-gui-react.zip
shell: powershell
- name: Replace string with current date (Windows)
if: runner.os == 'Windows'
run: |
$beijingTime = [System.TimeZoneInfo]::ConvertTimeFromUtc((Get-Date).ToUniversalTime(), [System.TimeZoneInfo]::FindSystemTimeZoneById('China Standard Time'))
$current_date = $beijingTime.ToString("yyyy-MM-dd")
$current_time = $beijingTime.ToString("HH:mm:ss")
$combined_date_time = "$current_date $current_time"
Write-Output $combined_date_time
(Get-Content Core/Init.cs) -replace 'CompilationTime', $combined_date_time | Set-Content Core/Init.cs
- name: Replace VerString (Windows)
if: runner.os == 'Windows'
run: |
$TAG_NAME = "${env:GITHUB_REF}".Replace("refs/tags/", "")
$VERSION_NUMBER = $TAG_NAME -replace ".*?(\d+\.\d+\.\d+).*", '$1'
$COMMIT_COUNT = git rev-list --count HEAD
$FINAL_VERSION = "$VERSION_NUMBER.$COMMIT_COUNT"
Write-Output $FINAL_VERSION
(Get-Content Core/Core.csproj) | Foreach-Object { $_ -replace "5.0.0.0", $FINAL_VERSION } | Set-Content Core/Core.csproj
(Get-Content Server/Server.csproj) | Foreach-Object { $_ -replace "5.0.0.0", $FINAL_VERSION } | Set-Content Server/Server.csproj
(Get-Content Desktop/Desktop.csproj) | Foreach-Object { $_ -replace "5.0.0.0", $FINAL_VERSION } | Set-Content Desktop/Desktop.csproj
shell: pwsh
- name: Build
run: cd Desktop && dotnet publish --runtime ${{ matrix.runtime }} --configuration Release --self-contained true --output build_output
- name: Build Update
run: cd Update && dotnet publish --runtime ${{ matrix.runtime }} --configuration Release --self-contained true --output build_update_output
- name: Move Update (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$source = "Update/build_update_output/*"
$destination = "Desktop/build_output/Update"
New-Item -ItemType Directory -Force -Path $destination
Move-Item -Path $source -Destination $destination
- name: Copy Static folder to build_output
run: cp -r Static Desktop/build_output/Static
- name: Copy ffmpeg.exe (Windows)
if: matrix.os == 'windows-latest'
run: |
mkdir Desktop\\build_output\\Plugins\\ffmpeg
copy Desktop\\Plugins\\ffmpeg\\ffmpeg.exe Desktop\\build_output\\Plugins\\ffmpeg\\ffmpeg.exe
- name: Copy VLC (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
mkdir Desktop/build_output/Plugins/vlc
$source = "Desktop/Plugins/vlc/*"
$destination = "Desktop/build_output/Plugins/vlc"
New-Item -ItemType Directory -Force -Path $destination
Move-Item -Path $source -Destination $destination
- name: Move all files to bin folder and create shortcut (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Get-ChildItem -Path "Desktop/build_output" | Move-Item -Destination "Desktop/build_output/bin"
$bat_file_path = "Desktop/build_output/启动DDTV_Desktop.bat"
$command = @"
setlocal EnableDelayedExpansion
set "abs_path=%~dp0"
cd %abs_path%bin
start Desktop.exe
"@
Set-Content -Path $bat_file_path -Value $command
- name: Add VersionFile (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$bat_file_path = "Desktop/build_output/bin/ver.ini"
$command = @"
type=DDTV-Desktop-${{ matrix.os }}-${{ matrix.runtime }}
ver=${{ github.ref_name }}
"@
Set-Content -Path $bat_file_path -Value $command
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: DDTV-Desktop-${{ matrix.os }}-${{ matrix.runtime }}
path: Desktop/build_output
Client:
strategy:
matrix:
include:
- os: windows-latest
runtime: win-x64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use .NET 8.x
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'
- name: Download and extract latest release (Windows)
if: runner.os == 'Windows'
run: |
mkdir Static
$header = @{
Authorization = "Bearer ${{ secrets.GITHUB_TOKEN }}"
}
$url = Invoke-RestMethod -Uri https://api.github.com/repos/moehuhu/DDTV_GUI_React/releases/latest -Headers $header
$fileUrl = $url.assets | Where-Object { $_.name -match "ddtv-gui-react_v.*\.zip" } | Select-Object -ExpandProperty browser_download_url
Invoke-WebRequest -Uri $fileUrl -OutFile ddtv-gui-react.zip -Headers $header
Expand-Archive -Path ddtv-gui-react.zip -DestinationPath Static
Remove-Item -Path ddtv-gui-react.zip
shell: powershell
- name: Replace string with current date (Windows)
if: runner.os == 'Windows'
run: |
$beijingTime = [System.TimeZoneInfo]::ConvertTimeFromUtc((Get-Date).ToUniversalTime(), [System.TimeZoneInfo]::FindSystemTimeZoneById('China Standard Time'))
$current_date = $beijingTime.ToString("yyyy-MM-dd")
$current_time = $beijingTime.ToString("HH:mm:ss")
$combined_date_time = "$current_date $current_time"
Write-Output $combined_date_time
(Get-Content Core/Init.cs) -replace 'CompilationTime', $combined_date_time | Set-Content Core/Init.cs
- name: Replace VerString (Windows)
if: runner.os == 'Windows'
run: |
$TAG_NAME = "${env:GITHUB_REF}".Replace("refs/tags/", "")
$VERSION_NUMBER = $TAG_NAME -replace ".*?(\d+\.\d+\.\d+).*", '$1'
$COMMIT_COUNT = git rev-list --count HEAD
$FINAL_VERSION = "$VERSION_NUMBER.$COMMIT_COUNT"
Write-Output $FINAL_VERSION
(Get-Content Core/Core.csproj) | Foreach-Object { $_ -replace "5.0.0.0", $FINAL_VERSION } | Set-Content Core/Core.csproj
(Get-Content Server/Server.csproj) | Foreach-Object { $_ -replace "5.0.0.0", $FINAL_VERSION } | Set-Content Server/Server.csproj
(Get-Content Client/Client.csproj) | Foreach-Object { $_ -replace "5.0.0.0", $FINAL_VERSION } | Set-Content Client/Client.csproj
shell: pwsh
- name: Build
run: cd Client && dotnet publish --runtime ${{ matrix.runtime }} --configuration Release --self-contained true --output build_output
- name: Build Update
run: cd Update && dotnet publish --runtime ${{ matrix.runtime }} --configuration Release --self-contained true --output build_update_output
- name: Move Update (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$source = "Update/build_update_output/*"
$destination = "Client/build_output/Update"
New-Item -ItemType Directory -Force -Path $destination
Move-Item -Path $source -Destination $destination
- name: Copy Static folder to build_output
run: cp -r Static Client/build_output/Static
- name: Copy ffmpeg.exe (Windows)
if: matrix.os == 'windows-latest'
run: |
mkdir Client\\build_output\\Plugins\\ffmpeg
copy Client\\Plugins\\ffmpeg\\ffmpeg.exe Client\\build_output\\Plugins\\ffmpeg\\ffmpeg.exe
- name: Move all files to bin folder and create shortcut (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Get-ChildItem -Path "Client/build_output" | Move-Item -Destination "Client/build_output/bin"
$bat_file_path = "Client/build_output/启动DDTV_Client.bat"
$command = @"
setlocal EnableDelayedExpansion
set "abs_path=%~dp0"
cd %abs_path%bin
start Client.exe
"@
Set-Content -Path $bat_file_path -Value $command
- name: Add VersionFile (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$bat_file_path = "Client/build_output/bin/ver.ini"
$command = @"
type=DDTV-Client-${{ matrix.os }}-${{ matrix.runtime }}
ver=${{ github.ref_name }}
"@
Set-Content -Path $bat_file_path -Value $command
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: DDTV-Client-${{ matrix.os }}-${{ matrix.runtime }}
path: Client/build_output