Skip to content

Commit

Permalink
👷 Updates Build Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
brucificus committed Sep 25, 2023
1 parent 82ab45a commit cd61b7a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 10 additions & 1 deletion build/funcs/Expand-PackageExportOutput.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function Expand-PackageExportOutput {
param(
)

$InformationPreference = "Continue"
[string] $ds = [System.IO.Path]::DirectorySeparatorChar
[string] $out = "${PSScriptRoot}${ds}..${ds}..${ds}out"

Expand Down Expand Up @@ -56,6 +57,13 @@ function Expand-PackageExportOutput {
throw "No psd1 file was found in '$moduleLocation' that matches '$psgalleryNupkgName'."
}

Write-Information "Cleaning up NuPkg artifacts."
[string[]] $cleanupFilePatternsToDelete = @("[Content_Types].xml", "*.nuspec", "_rels", "package")
foreach ($cleanupFilePatternToDelete in $cleanupFilePatternsToDelete) {
@(Get-ChildItem -Path $moduleLocation -Filter $cleanupFilePatternToDelete -Force) `
| ForEach-Object { Write-Information ("Removing: " + $_.FullName); Remove-Item -LiteralPath $_.FullName -Force -Recurse -ErrorAction Continue }
}

# Move the expanded NuPkg to the psd1's name, which is a requirement before it can be imported.
Write-Information "Renaming folder '$moduleLocation' to match the module name."
[string] $newModuleLocation = $null
Expand All @@ -64,6 +72,7 @@ function Expand-PackageExportOutput {
Remove-Item -Path $newModuleLocation -Recurse -Force | Out-Null
}
$moduleLocation = (Rename-Item -Path $moduleLocation -NewName $psd1.BaseName -Force -PassThru).FullName
$psd1 = Get-ChildItem -Path (Join-Path -Path $moduleLocation -ChildPath $psd1.Name) -File -Force | Select-Object -First 1
$psd1 = Get-Item -Path (Join-Path -Path $moduleLocation -ChildPath $psd1.Name) | Select-Object -First 1

return $psd1
}
4 changes: 3 additions & 1 deletion build/publish.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ param(
[switch] $WhatIf
)
$ErrorActionPreference = "Stop"
$InformationPreference = "Continue"
Set-StrictMode -Version Latest


[string] $ds = [System.IO.Path]::DirectorySeparatorChar
. "${PSScriptRoot}${ds}funcs${ds}Expand-PackageExportOutput.ps1"
[System.IO.FileInfo] $psd1 = Expand-PackageExportOutput
[hashtable] $psd1Data = Import-PowerShellDataFile -Path $psd1.FullName
[string] $expandedModulePath = $psd1.Directory.FullName

Publish-Module `
-Path (Split-Path $psd1 -Parent) `
-Path $expandedModulePath `
-NuGetApiKey $NUGET_KEY `
-ReleaseNotes $psd1Data.PrivateData.PSData.ReleaseNotes `
-Tags $psd1Data.PrivateData.PSData.Tags `
Expand Down

0 comments on commit cd61b7a

Please sign in to comment.