diff --git a/build_scripts/build.ps1 b/build_scripts/build.ps1 new file mode 100644 index 0000000..030fcf6 --- /dev/null +++ b/build_scripts/build.ps1 @@ -0,0 +1,27 @@ +$Global:ErrorActionPreference = 'Stop' +$Global:VerbosePreference = 'SilentlyContinue' + +$buildVersion = $env:BUILDVER +$manifestPath = "./ClickUpAPI/ClickUpAPI.psd1" +$publicFuncFolderPath = './ClickUpAPI/Public' + + +if (!(Get-PackageProvider | Where-Object { $_.Name -eq 'NuGet' })) { + Install-PackageProvider -Name NuGet -force | Out-Null +} +Import-PackageProvider -Name NuGet -force | Out-Null + +if ((Get-PSRepository -Name PSGallery).InstallationPolicy -ne 'Trusted') { + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted +} + +$manifestContent = (Get-Content -Path $manifestPath -Raw) -replace '', $buildVersion + +if ((Test-Path -Path $publicFuncFolderPath) -and ($publicFunctionNames = Get-ChildItem -Path $publicFuncFolderPath -Filter '*.ps1' | Select-Object -ExpandProperty BaseName)) { + $funcStrings = "'$($publicFunctionNames -join "','")'" +} else { + $funcStrings = $null +} + +$manifestContent = $manifestContent -replace "''", $funcStrings +$manifestContent | Set-Content -Path $manifestPath