@@ -14,8 +14,42 @@ concurrency:
1414 cancel-in-progress : true
1515
1616jobs :
17+ prepare-host-rg :
18+ name : Prepare host ripgrep
19+ runs-on : windows-2022
20+
21+ steps :
22+ - name : Restore ripgrep host tool
23+ id : cache-rg
24+ uses : actions/cache@v4
25+ with :
26+ path : ${{ runner.temp }}\ripgrep-14.1.1-x86_64-pc-windows-msvc
27+ key : ripgrep-14.1.1-x86_64-pc-windows-msvc
28+
29+ - name : Install ripgrep host tool
30+ if : steps.cache-rg.outputs.cache-hit != 'true'
31+ shell : pwsh
32+ run : |
33+ $rgVersion = '14.1.1'
34+ $archive = Join-Path $env:RUNNER_TEMP "ripgrep-$rgVersion-x86_64-pc-windows-msvc.zip"
35+ $extractRoot = $env:RUNNER_TEMP
36+ Invoke-WebRequest `
37+ -Uri "https://github.com/BurntSushi/ripgrep/releases/download/$rgVersion/ripgrep-$rgVersion-x86_64-pc-windows-msvc.zip" `
38+ -OutFile $archive
39+ Expand-Archive -Path $archive -DestinationPath $extractRoot -Force
40+
41+ - name : Verify ripgrep host tool
42+ shell : pwsh
43+ run : |
44+ $rgExe = Join-Path $env:RUNNER_TEMP 'ripgrep-14.1.1-x86_64-pc-windows-msvc\rg.exe'
45+ if (-not (Test-Path $rgExe)) {
46+ throw "ripgrep was not installed on host."
47+ }
48+ & $rgExe --version
49+
1750 build-windows :
1851 name : Nabla (${{ matrix.os }}, ${{ matrix.vendor }}-${{ matrix.tag }}, ${{ matrix.config }})
52+ needs : prepare-host-rg
1953 runs-on : ${{ matrix.os }}
2054
2155 env :
@@ -124,6 +158,24 @@ jobs:
124158 with :
125159 submodules : ' recursive'
126160
161+ - name : Restore ripgrep host tool
162+ id : cache-rg
163+ uses : actions/cache@v4
164+ with :
165+ path : ${{ runner.temp }}\ripgrep-14.1.1-x86_64-pc-windows-msvc
166+ key : ripgrep-14.1.1-x86_64-pc-windows-msvc
167+
168+ - name : Add ripgrep to PATH
169+ shell : pwsh
170+ run : |
171+ $rgDir = Join-Path $env:RUNNER_TEMP 'ripgrep-14.1.1-x86_64-pc-windows-msvc'
172+ $rgExe = Join-Path $rgDir 'rg.exe'
173+ if (-not (Test-Path $rgExe)) {
174+ throw "ripgrep was not installed on host."
175+ }
176+ $rgDir | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
177+ & $rgExe --version
178+
127179 - name : Pull Image
128180 run : |
129181 docker pull "${{ env.image }}:${{ matrix.tag }}"
@@ -297,6 +349,39 @@ jobs:
297349 run : |
298350 tar -cvf "${{ steps.set-prefix.outputs.prefix }}-profiling.tar" profiling
299351 tar -cvf "${{ steps.set-prefix.outputs.prefix }}-install.tar" ${{ env.install }}
352+ $sourceTar = "${{ steps.set-prefix.outputs.prefix }}-source.tar"
353+ $sourceFiles = @(
354+ rg --files -uu . `
355+ -g '*.c' -g '*.cc' -g '*.cpp' -g '*.cxx' `
356+ -g '*.h' -g '*.hh' -g '*.hpp' -g '*.hxx' `
357+ -g '*.inc' -g '*.inl' -g '*.ipp' -g '*.tpp' -g '*.ixx' `
358+ -g '!examples_tests/media/**' -g '!.git/**'
359+ ) | Sort-Object -Unique
360+
361+ if ($sourceFiles.Count -eq 0) {
362+ throw "No source-like files found for source artifact packaging."
363+ }
364+
365+ $archiveStream = [System.IO.File]::Open($sourceTar, [System.IO.FileMode]::Create, [System.IO.FileAccess]::Write, [System.IO.FileShare]::None)
366+ try {
367+ $tarWriter = [System.Formats.Tar.TarWriter]::new($archiveStream, [System.Formats.Tar.TarEntryFormat]::Pax, $false)
368+ try {
369+ foreach ($sourceFile in $sourceFiles) {
370+ $entryName = $sourceFile -replace '\\', '/'
371+ if ($entryName.StartsWith('./')) {
372+ $entryName = $entryName.Substring(2)
373+ }
374+ $sourcePath = (Resolve-Path -LiteralPath $sourceFile).Path
375+ $tarWriter.WriteEntry($sourcePath, $entryName)
376+ }
377+ }
378+ finally {
379+ $tarWriter.Dispose()
380+ }
381+ }
382+ finally {
383+ $archiveStream.Dispose()
384+ }
300385
301386 - name : Upload NSC Godbolt Image artifact
302387 uses : actions/upload-artifact@v4
@@ -331,6 +416,12 @@ jobs:
331416 name : ${{ steps.set-prefix.outputs.prefix }}-install
332417 path : ${{ steps.set-prefix.outputs.prefix }}-install.tar
333418
419+ - name : Upload source artifacts
420+ uses : actions/upload-artifact@v4
421+ with :
422+ name : ${{ steps.set-prefix.outputs.prefix }}-source
423+ path : ${{ steps.set-prefix.outputs.prefix }}-source.tar
424+
334425 - name : Login to GHCR
335426 if : steps.set-prefix.outputs.shouldPushImage == 'True'
336427 run : echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u $env:GITHUB_ACTOR --password-stdin
0 commit comments