Skip to content

Commit

Permalink
ci: refactor consolidation script
Browse files Browse the repository at this point in the history
  • Loading branch information
dansiegel committed Jun 3, 2023
1 parent c00d0e1 commit 193c933
Showing 1 changed file with 35 additions and 9 deletions.
44 changes: 35 additions & 9 deletions build/consolidate-artifacts.ps1
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
# Ensure artifacts directory is clean
Get-ChildItem .\ -Include artifacts -Recurse | ForEach-Object ($_) { Remove-Item $_.Fullname -Force -Recurse }
Get-ChildItem .\ -Include .\artifacts\binaries -Recurse | ForEach-Object ($_) { Remove-Item $_.Fullname -Force -Recurse }
Get-ChildItem .\ -Include .\artifacts\nuget -Recurse | ForEach-Object ($_) { Remove-Item $_.Fullname -Force -Recurse }
New-Item -Path artifacts\binaries -ItemType Directory -Force
New-Item -Path artifacts\nuget -ItemType Directory -Force
$platforms = @('Forms', 'Wpf', 'Uno', 'Maui')
$platformNuGet = $platforms | ForEach-Object { Join-Path -Path .\artifacts -ChildPath "$_\NuGet" }
$platformBinary = $platforms | ForEach-Object { Join-Path -Path .\artifacts -ChildPath "$_\Release" }
Get-ChildItem $platformNuGet -Filter '*.nupkg' | Where-Object { $_.Name.StartsWith('Prism.Core') -eq $false -and $_.Name.StartsWith('Prism.Events') -eq $false } | ForEach-Object { if(!(Test-Path -Path $_.FullName)) { Copy-Item $_.FullName .\artifacts\nuget }else { Write-Warning "File already exists: $($_.FullName)" } }
Get-ChildItem $platformNuGet -Filter '*.snupkg' | Where-Object { $_.Name.StartsWith('Prism.Core') -eq $false -and $_.Name.StartsWith('Prism.Events') -eq $false } | ForEach-Object { if(!(Test-Path -Path $_.FullName)) { Copy-Item $_.FullName .\artifacts\nuget }else { Write-Warning "File already exists: $($_.FullName)" } }
Get-ChildItem $platformBinary | Where-Object { $_.Name -ne 'Core' } | ForEach-Object { if(!(Test-Path -Path $_.FullName)) { Copy-Item $_.FullName .\artifacts\binaries }else { Write-Warning "File already exists: $($_.FullName)" } }
Get-ChildItem .\artifacts\Core\NuGet -Filter '*.nupkg' | ForEach-Object { if(!(Test-Path -Path $_.FullName)) { Copy-Item $_.FullName .\artifacts\nuget }else { Write-Warning "File already exists: $($_.FullName)" } }
Get-ChildItem .\artifacts\Core\NuGet -Filter '*.snupkg' | ForEach-Object { if(!(Test-Path -Path $_.FullName)) { Copy-Item $_.FullName .\artifacts\nuget }else { Write-Warning "File already exists: $($_.FullName)" } }
Get-ChildItem .\artifacts\Core\Release | ForEach-Object { if(!(Test-Path -Path $_.FullName)) { Copy-Item $_.FullName .\artifacts\binaries }else { Write-Warning "File already exists: $($_.FullName)" } }

$core = @("Prism.Core", "Prism.Events", "Prism.dll", "Prism.pdb", "Prism.xml")
$files = Get-ChildItem -Path .\artifacts -Filter "*" -Recurse | Where-Object { (Test-Path -Path $_.FullName -PathType Leaf) -and $_.FullName -notmatch "artifacts\\binaries|artifacts\\nuget" }

foreach($file in $files)
{
if ($file -match ($platforms -join '|') -and $file -match ($core -join '|'))
{
continue
}
elseif ($file -like "*.nupkg" -or $file -like "*.snupkg")
{
Write-Information "Copying $file to .\artifacts\nuget"
Copy-Item $file.FullName .\artifacts\nuget
}
else
{
$parent = Split-Path -Path $file -Parent
$parentDirName = Split-Path -Path $parent -Leaf

if($parentDirName -like ($platforms -join '|') -or $parentDirName -like 'Core')
{
continue
}

$copyPath = Join-Path .\artifacts\binaries -ChildPath $parentDirName

Write-Information "Creating $copyPath"
New-Item -Path $copyPath -ItemType Directory -Force
Write-Information "Copying $file to $copyPath"
Copy-Item $file.FullName $copyPath
}
}

Remove-Item artifacts\Core -Recurse
Remove-Item artifacts\Wpf -Recurse
Expand Down

0 comments on commit 193c933

Please sign in to comment.