-
Notifications
You must be signed in to change notification settings - Fork 0
651 lines (579 loc) · 22.1 KB
/
Copy pathmanual.yml
File metadata and controls
651 lines (579 loc) · 22.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
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
# This is a basic workflow that is manually triggered
name: Manual Build
# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
run_windows:
description: 'Run Windows build'
type: boolean
default: true
run_linux:
description: 'Run Linux build'
type: boolean
default: false
run_macos:
description: 'Run macOS build'
type: boolean
default: false
run_freebsd:
description: 'Run FreeBSD build'
type: boolean
default: false
name:
# Friendly description to be shown in the UI instead of 'name'
description: 'DSvC Build workflow'
# Default value if no value is explicitly provided
default: 'World'
# Input has to be provided for the workflow to run
required: false
# The data type of the input
type: string
jobs:
build-windows:
if: ${{ github.event.inputs.run_windows == 'true' }}
runs-on: windows-latest
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
VCPKG_ROOT: C:\vcpkg
OPENSSL_DIR: C:/vcpkg/installed/x64-windows-static
OPENSSL_STATIC: 1
OPENSSL_LIB_DIR: C:/vcpkg/installed/x64-windows-static/lib
OPENSSL_INCLUDE_DIR: C:/vcpkg/installed/x64-windows-static/include
CMAKE_TOOLCHAIN_FILE: C:/vcpkg/scripts/buildsystems/vcpkg.cmake
steps:
- uses: actions/checkout@v3
- name: Cache Cargo Dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
# Windows specific paths
C:/Users/runneradmin/.cargo/registry
C:/Users/runneradmin/.cargo/git
# Cache build artifacts
target
target/x86_64-pc-windows-msvc
target/x86_64-pc-windows-msvc/release
target/release
key: ${{ runner.os }}-msvc-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/rust-toolchain.toml', '.cargo/config*') }}
restore-keys: |
${{ runner.os }}-msvc-cargo-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-msvc-cargo-
- name: Cache custom tools (Windows)
uses: actions/cache@v3
id: custom-tools-cache
with:
path: |
C:/tools
C:/tools/psutils
C:/ProgramData/chocolatey/lib/dos2unix
C:/ProgramData/chocolatey/lib/7zip.install
~/.cargo/bin/sccache
C:/Users/runneradmin/.cargo/bin/sccache
C:/Users/runneradmin/.cargo/config.toml
key: windows-custom-tools-v4-${{ hashFiles('**/Cargo.lock') }}
- name: Cache vcpkg (Windows)
uses: actions/cache@v3
with:
path: C:/vcpkg/installed
key: windows-vcpkg-${{ hashFiles('**/Cargo.lock') }}
restore-keys: windows-vcpkg-
- name: Add tools to PATH (Windows)
shell: pwsh
run: |
echo "C:/tools" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "C:/tools/psutils" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
path: C:/Users/runneradmin/.rustup
key: windows-rustup-${{ hashFiles('**/Cargo.lock') }}
restore-keys: windows-rustup-
- name: Cache Release Artifacts
id: cache-release
uses: actions/cache@v3
with:
path: |
target/x86_64-pc-windows-msvc/release
target/release
Changes.md
key: windows-release-${{ hashFiles('target/x86_64-pc-windows-msvc/release/**', 'target/release/**') }}
restore-keys: |
windows-release-
- name: Install Dependencies (Windows)
shell: pwsh
run: |
vcpkg integrate install
vcpkg install openssl:x64-windows-static
# Set OpenSSL environment variables for Windows
echo "OPENSSL_DIR=C:/vcpkg/installed/x64-windows-static" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "OPENSSL_STATIC=1" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "OPENSSL_LIB_DIR=C:/vcpkg/installed/x64-windows-static/lib" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "OPENSSL_INCLUDE_DIR=C:/vcpkg/installed/x64-windows-static/include" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-pc-windows-msvc
profile: minimal
override: true
- name: Create Changes.md
if: steps.cache-release.outputs.cache-hit != 'true'
run: |
echo "# Changelog" > Changes.md
echo "## v0.1.0" >> Changes.md
echo "* Initial release" >> Changes.md
shell: bash
- name: Download custom tools (Windows)
if: steps.custom-tools-cache.outputs.cache-hit != 'true'
shell: pwsh
run: |
# Create tools directory first
if (-not (Test-Path "C:/tools")){
New-Item -Path "C:/tools" -ItemType Directory -Force
New-Item -Path "C:/tools/psutils" -ItemType Directory -Force
}
# Install tools first so they're available in PATH
choco install 7zip.install --version=24.9.0 -y --no-progress
choco install dos2unix -y
# Download and install psutils after other tools
$psutilsPath = "C:/tools/psutils"
$tempZip = "C:/tools/psutils.zip"
Invoke-WebRequest -Uri "https://github.com/lukesampson/psutils/archive/master.zip" -OutFile $tempZip
Expand-Archive -Path $tempZip -DestinationPath $psutilsPath -Force
Remove-Item $tempZip
Get-ChildItem -Path "$psutilsPath/psutils-master" -Filter "*.ps1" |
ForEach-Object { Copy-Item $_.FullName -Destination $psutilsPath }
Remove-Item "$psutilsPath/psutils-master" -Recurse -Force
- name: Configure Cargo
if: steps.custom-tools-cache.outputs.cache-hit != 'true'
shell: pwsh
run: |
cargo install sccache
# Add cache configuration
$cargoConfig = @"
[build]
target-dir = "./target"
[net]
retry = 10
"@
New-Item -Path "$env:USERPROFILE\.cargo" -ItemType Directory -Force
Set-Content -Path "$env:USERPROFILE\.cargo\config.toml" -Value $cargoConfig
- name: Build Release
#if: steps.cache-release.outputs.cache-hit != 'true'
shell: pwsh
run: |
Write-Host "Current directory: $(Get-Location)"
Write-Host "Environment variables:"
Get-ChildItem env:
# Create target directory if it doesn't exist
New-Item -Path "target" -ItemType Directory -Force
# Build with explicit target directory
$env:CARGO_TARGET_DIR = Join-Path (Get-Location) "target"
cargo build --release --target x86_64-pc-windows-msvc --verbose
Write-Host "`nSearching for binary..."
Get-ChildItem -Path "." -Recurse -Filter "DSvClient*" | ForEach-Object {
Write-Host "Found: $($_.FullName)"
}
# Look in both possible locations
$possiblePaths = @(
"target/x86_64-pc-windows-msvc/release/DSvClient.exe",
"./target/x86_64-pc-windows-msvc/release/DSvClient.exe",
"target/release/DSvClient.exe",
"./target/release/DSvClient.exe"
)
$binPath = $null
foreach ($path in $possiblePaths) {
if (Test-Path $path) {
$binPath = $path
break
}
}
if ($binPath) {
Write-Host "`nBinary found at: $binPath"
Get-Item $binPath | Select-Object FullName, Length, LastWriteTime
# Ensure binary is in the expected location
$targetPath = "target/x86_64-pc-windows-msvc/release/DSvClient.exe"
if ($binPath -ne $targetPath) {
New-Item -Path (Split-Path $targetPath) -ItemType Directory -Force
Copy-Item $binPath $targetPath -Force
}
} else {
Write-Host "`nChecking directory structure:"
Get-ChildItem -Path "." -Recurse | Select-Object FullName
Write-Error "Binary not found in any expected location"
exit 1
}
# Removed strip binary (windows) - does nothing for size and uses a lot of time
- name: Verify Binary
shell: pwsh
run: |
$paths = @(
"target/x86_64-pc-windows-msvc/release/DSvClient.exe",
"target/release/DSvClient.exe"
)
foreach ($path in $paths) {
if (Test-Path $path) {
Write-Host "Found binary at: $path"
Get-Item $path | Select-Object FullName, Length, LastWriteTime
}
}
- name: Upload Windows Artifact
uses: actions/upload-artifact@v4
with:
name: DSvClient-windows
path: target/x86_64-pc-windows-msvc/release/DSvClient.exe
retention-days: 7
if-no-files-found: error
- name: Publish Release
#if: steps.cache-release.outputs.cache-hit != 'true'
uses: houseabsolute/actions-rust-release@v0
with:
executable-name: DSvClient
target: x86_64-pc-windows-msvc
changes-file: Changes.md
build-ubuntu:
if: ${{ github.event.inputs.run_linux == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache Cargo Dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
target/x86_64-unknown-linux-gnu
target/x86_64-unknown-linux-gnu/release
target/release
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
${{ runner.os }}-cargo-
- name: Cache Build Release
uses: actions/cache@v3
with:
path: |
target/x86_64-unknown-linux-gnu/release
target/release
key: ubuntu-release-${{ hashFiles('target/x86_64-unknown-linux-gnu/release/**', 'target/release/**') }}
restore-keys: |
ubuntu-release-
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
path: ~/.rustup
key: linux-rustup-${{ hashFiles('**/Cargo.lock') }}
restore-keys: linux-rustup-
- name: Install Dependencies (Linux)
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libssl-dev
# Set OpenSSL paths for Linux
echo "OPENSSL_LIB_DIR=/usr/lib/x86_64-linux-gnu" >> $GITHUB_ENV
echo "OPENSSL_INCLUDE_DIR=/usr/include/openssl" >> $GITHUB_ENV
echo "OPENSSL_DIR=/usr" >> $GITHUB_ENV
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-linux-gnu
profile: minimal
override: true
- name: Create Changes.md
run: |
echo "# Changelog" > Changes.md
echo "## v0.1.0" >> Changes.md
echo "* Initial release" >> Changes.md
shell: bash
- name: Build Release
uses: houseabsolute/actions-rust-cross@v0
with:
target: x86_64-unknown-linux-gnu
args: "--locked --release"
strip: true
- name: Upload Linux Artifact
uses: actions/upload-artifact@v4
with:
name: DSvClient-linux
path: target/x86_64-unknown-linux-gnu/release/DSvClient
retention-days: 7
if-no-files-found: error
- name: Publish Release
uses: houseabsolute/actions-rust-release@v0
with:
executable-name: DSvClient
target: x86_64-unknown-linux-gnu
changes-file: Changes.md
build-macos:
if: ${{ github.event.inputs.run_macos == 'true' }}
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Cache Cargo Dependencies
uses: actions/cache@v3
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: macos-cargo-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', 'rust-toolchain.toml') }}
restore-keys: |
macos-cargo-
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
path: ~/.rustup
key: macos-rustup-${{ hashFiles('**/Cargo.lock') }}
restore-keys: macos-rustup-
- name: Install Dependencies (macOS)
shell: bash
run: |
echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV
echo "OPENSSL_LIB_DIR=$(brew --prefix openssl@3)/lib" >> $GITHUB_ENV
echo "OPENSSL_INCLUDE_DIR=$(brew --prefix openssl@3)/include" >> $GITHUB_ENV
- name: Create Changes.md
run: |
echo "# Changelog" > Changes.md
echo "## v0.1.0" >> Changes.md
echo "* Initial release" >> Changes.md
shell: bash
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-apple-darwin
profile: minimal
override: true
- name: Build Release
uses: houseabsolute/actions-rust-cross@v0
with:
target: x86_64-apple-darwin
args: "--locked --release"
strip: true
- name: Upload macOS Artifact
uses: actions/upload-artifact@v4
with:
name: DSvClient-macos
path: target/x86_64-apple-darwin/release/DSvClient
retention-days: 7
if-no-files-found: error
- name: Publish Release
uses: houseabsolute/actions-rust-release@v0
with:
executable-name: DSvClient
target: x86_64-apple-darwin
changes-file: Changes.md
build-freebsd:
if: ${{ github.event.inputs.run_freebsd == 'true' }}
runs-on: ubuntu-20.04
env:
CARGO_HOME: /home/runner/.cargo
CROSS_CARGO_HOME: /home/runner/.cargo
steps:
- uses: actions/checkout@v3
- name: Cache FreeBSD Dependencies
uses: actions/cache@v3
id: freebsd-deps-cache
with:
path: |
/home/runner/.cargo/registry
/home/runner/.cargo/git
/home/runner/.cargo/bin
/home/runner/.cargo/config*
target
target/x86_64-unknown-freebsd
target/x86_64-unknown-freebsd/release
target/release
target/debug
target/.rustc_info.json
target/CACHEDIR.TAG
key: freebsd-cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml', '**/rust-toolchain.toml', '.cargo/config*') }}
restore-keys: |
freebsd-cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
freebsd-cargo-${{ runner.os }}-
- name: Setup System Dependencies
run: |
# Create backup of system SSL files with proper permissions
sudo mkdir -p /opt/ssl_backup
cd /opt/ssl_backup
sudo tar czf ssl_libs.tar.gz \
/usr/lib/x86_64-linux-gnu/libssl* \
/usr/lib/x86_64-linux-gnu/libcrypto* \
/usr/include/openssl
sudo chown $(id -u):$(id -g) ssl_libs.tar.gz
shell: bash
- name: Cache System Libraries
uses: actions/cache@v3
id: system-libs-cache
with:
path: /opt/ssl_backup/ssl_libs.tar.gz
key: freebsd-ssl-${{ hashFiles('/usr/lib/x86_64-linux-gnu/libssl*', '/usr/lib/x86_64-linux-gnu/libcrypto*') }}
- name: Restore System Libraries
if: steps.system-libs-cache.outputs.cache-hit == 'true'
run: |
cd /
sudo tar xzf /opt/ssl_backup/ssl_libs.tar.gz
shell: bash
- name: Pre-cache cleanup
run: |
# Remove lock files and partial directories before caching
sudo rm -f /var/lib/apt/lists/lock
sudo rm -f /var/cache/apt/archives/lock
sudo rm -rf /var/lib/apt/lists/partial/
sudo rm -rf /var/cache/apt/archives/partial/
# Set permissions for caching
sudo chown -R $(id -u):$(id -g) /var/lib/apt/lists/
sudo chown -R $(id -u):$(id -g) /var/cache/apt/archives/
# Other cleanup
sudo rm -rf /tmp/*
sudo rm -rf /var/tmp/*
sudo rm -rf ~/.cache/cross-rs/*
shell: bash
- name: Cache apt packages
uses: actions/cache@v3
id: apt-cache
with:
path: |
/var/lib/apt/lists
/var/cache/apt/archives
key: ${{ runner.os }}-apt-${{ hashFiles('/var/lib/apt/lists/*', '/var/cache/apt/archives/*.deb') }}
restore-keys: |
${{ runner.os }}-apt-${{ github.ref_name }}-
${{ runner.os }}-apt-
- name: Cache Build Release
uses: actions/cache@v3
with:
path: |
target/x86_64-unknown-freebsd/release
target/release
key: freebsd-release-${{ hashFiles('target/x86_64-unknown-freebsd/release/**', 'target/release/**') }}
restore-keys: |
freebsd-release-
- name: Cache Rust toolchain
uses: actions/cache@v3
with:
path: ~/.rustup
key: freebsd-rustup-${{ hashFiles('**/Cargo.lock') }}
restore-keys: freebsd-rustup-
- name: Cache cross compiled artifacts (FreeBSD)
uses: actions/cache@v3
with:
path: target/x86_64-unknown-freebsd
key: freebsd-cargo-compiled-${{ hashFiles('**/Cargo.lock') }}
restore-keys: freebsd-cargo-compiled-
- name: Cache cross Docker image
uses: actions/cache@v3
id: cached-image
with:
path: ${{ runner.temp }}/freebsd-cross.tar
key: freebsd-cross-${{ hashFiles('**/Cargo.lock') }}
- name: Load cross Docker image
if: steps.cached-image.outputs.cache-hit == 'true'
run: docker load -i $RUNNER_TEMP/freebsd-cross.tar
- name: Pull and Save cross Docker image
if: steps.cached-image.outputs.cache-hit != 'true'
run: |
docker pull ghcr.io/cross-rs/x86_64-unknown-freebsd:0.2.5
docker save ghcr.io/cross-rs/x86_64-unknown-freebsd:0.2.5 -o $RUNNER_TEMP/freebsd-cross.tar
- name: Setup Build Environment
run: |
# Remove old references
echo "Skipping manual FreeBSD libraries..."
sudo rm -rf /usr/local/freebsd
sudo rm -rf /usr/cross/freebsd
# Create cache directory if it doesn't exist
mkdir -p ~/.cache/cross-rs
# Only install the Rust target
rustup target add x86_64-unknown-freebsd
shell: bash
- name: Install Dependencies (FreeBSD)
run: |
# Only update apt if cache was not found
if [ "${{ steps.apt-cache.outputs.cache-hit }}" != 'true' ]; then
sudo apt-get update
fi
sudo apt-get install -y pkg-config libssl-dev
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: x86_64-unknown-freebsd
profile: minimal
override: true
- name: Cache Build Outputs
uses: actions/cache@v3
id: cache-build
with:
path: |
target/x86_64-unknown-freebsd/release/
target/release/
target/x86_64-unknown-freebsd/release/deps/
target/x86_64-unknown-freebsd/release/build/
target/release/deps/
target/release/build/
Changes.md
key: freebsd-build-${{ hashFiles('Cargo.toml', 'Cargo.lock', 'src/**/*.rs') }}
restore-keys: |
freebsd-build-
- name: Build Release
# if: steps.cache-build.outputs.cache-hit != 'true'
uses: houseabsolute/actions-rust-cross@v0
with:
target: x86_64-unknown-freebsd
args: "--locked --release"
strip: true
- name: Verify Build Artifacts
run: |
ls -la target/x86_64-unknown-freebsd/release/ || true
ls -la target/release/ || true
shell: bash
- name: Upload FreeBSD Artifact
uses: actions/upload-artifact@v4
with:
name: DSvClient-freebsd
path: target/x86_64-unknown-freebsd/release/DSvClient
retention-days: 7
if-no-files-found: error
- name: Create Changes.md
if: steps.cache-build.outputs.cache-hit != 'true'
run: |
echo "# Changelog" > Changes.md
echo "## v0.1.0" >> Changes.md
echo "* Initial release" >> Changes.md
shell: bash
- name: Post-build cleanup
if: always()
run: |
# Remove lock files and partial directories
sudo rm -f /var/lib/apt/lists/lock
sudo rm -f /var/cache/apt/archives/lock
sudo rm -rf /var/lib/apt/lists/partial/
sudo rm -rf /var/cache/apt/archives/partial/
# Clean up other directories
sudo rm -rf /tmp/*
sudo rm -rf /var/tmp/*
sudo rm -rf ~/.cargo/.git
sudo rm -rf target/debug
sudo rm -rf target/release/deps
sudo rm -rf target/release/build
# Reset permissions
sudo chown -R root:root /var/lib/apt/lists/
sudo chown -R root:root /var/cache/apt/archives/
shell: bash
- name: Publish Release
#if: steps.cache-build.outputs.cache-hit != 'true'
uses: houseabsolute/actions-rust-release@v0
with:
executable-name: DSvClient
target: x86_64-unknown-freebsd
changes-file: Changes.md