Skip to content

Commit d596885

Browse files
committed
Package source artifacts with .NET tar writer
1 parent f1dde84 commit d596885

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

.github/workflows/build-nabla.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,21 +350,38 @@ jobs:
350350
tar -cvf "${{ steps.set-prefix.outputs.prefix }}-profiling.tar" profiling
351351
tar -cvf "${{ steps.set-prefix.outputs.prefix }}-install.tar" ${{ env.install }}
352352
$sourceTar = "${{ steps.set-prefix.outputs.prefix }}-source.tar"
353-
$sourceList = "${{ steps.set-prefix.outputs.prefix }}-source-files.txt"
354353
$sourceFiles = @(
355354
rg --files -uu . `
356355
-g '*.c' -g '*.cc' -g '*.cpp' -g '*.cxx' `
357356
-g '*.h' -g '*.hh' -g '*.hpp' -g '*.hxx' `
358357
-g '*.inc' -g '*.inl' -g '*.ipp' -g '*.tpp' -g '*.ixx' `
359358
-g '!examples_tests/media/**' -g '!.git/**'
360-
)
359+
) | Sort-Object -Unique
361360
362361
if ($sourceFiles.Count -eq 0) {
363362
throw "No source-like files found for source artifact packaging."
364363
}
365364
366-
$sourceFiles | Sort-Object -Unique | Set-Content -Path $sourceList -Encoding utf8
367-
tar -cvf $sourceTar -T $sourceList
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+
}
368385
369386
- name: Upload NSC Godbolt Image artifact
370387
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)