ExcelCoordinate.build.ps1
|
task Test { $basePath = Get-Location $scriptPath = [System.IO.Path]::Join($basePath, "cp-21lid.ExcelCoordinate.ps1") $testPath = [System.IO.Path]::Join($basePath, "cp-21lid.ExcelCoordinateTests.ps1") . $scriptPath . $testPath Import-Module -Name Pester $config = New-PesterConfiguration $config.Run.Path = $testPath $config.CodeCoverage.Enabled = $true $config.CodeCoverage.Path = $scriptPath $config.CodeCoverage.CoveragePercentTarget = 80 $config.CodeCoverage.OutputFormat = 'CoverageGutters' $config.CodeCoverage.OutputPath = 'cov.xml' $config.CodeCoverage.OutputEncoding = 'UTF8' $testResults = Invoke-Pester -Configuration $config if ($testResults.FailedCount -gt 0) { throw "Tests failed. Please check the test results" } } task Release { # Mise à jour du fichier module $ps1Path = "./cp-21lid.ExcelCoordinate.ps1" $psm1Path = "./cp-21lid.ExcelCoordinate.psm1" Copy-Item -Path $ps1Path -Destination $psm1Path -Force Write-Output "Module file updated." # Upgrade du manifest (incrémentation de la version) $psd1Path = "./cp-21lid.ExcelCoordinate.psd1" $manifest = Test-ModuleManifest -Path $psd1Path $version = [version]$manifest.Version $newVersion = [version]::new($version.Major, $version.Minor, $version.Build + 1) Update-ModuleManifest -Path $psd1Path -ModuleVersion $newVersion Write-Output "Module manifest version updated to $newVersion." if (Test-Path "./.env" -PathType Leaf) { Get-Content .env | ForEach-Object { $name, $value = $_.Split('=') Set-Content env:\$name $value } } Publish-PSResource -Path $psd1Path -Repository PSGallery -ApiKey $env:PSGALLERY_APIKEY } task . Test, Release |