From 4ac32983cf9fc725c32a05eec9b5c3d634244c69 Mon Sep 17 00:00:00 2001 From: nohwnd Date: Tue, 11 Dec 2018 18:54:13 +0100 Subject: [PATCH] Add build and signing scripts --- CHANGELOG.md | 4 ++++ Pester.Tests.ps1 | 2 +- Pester.psd1 | 4 ++-- cleanUpBeforeBuild.ps1 | 10 ++++++---- release.ps1 | 32 ++++++++++++++++++++++++++++++ signModule.ps1 | 6 ++++-- testRelease.ps1 | 45 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 94 insertions(+), 9 deletions(-) create mode 100644 release.ps1 create mode 100644 testRelease.ps1 diff --git a/CHANGELOG.md b/CHANGELOG.md index 173fe4aa1..42c5e5874 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 4.4.3 (December 11, 2018) + - Add signing scripts + - Same as 4.4.3-beta1 but signed + ## 4.4.3-beta1 (November 27, 2018) - Fix InModuleScope when using unbound scriptBlock [GH-1146] - Allow multiple aliases for an assertion [GH-1122] diff --git a/Pester.Tests.ps1 b/Pester.Tests.ps1 index 0722c4e5e..fd78b385b 100644 --- a/Pester.Tests.ps1 +++ b/Pester.Tests.ps1 @@ -585,4 +585,4 @@ InModuleScope -ModuleName Pester { Should -BeTrue } } -} \ No newline at end of file +} diff --git a/Pester.psd1 b/Pester.psd1 index cdc9008a0..78e925888 100644 --- a/Pester.psd1 +++ b/Pester.psd1 @@ -122,10 +122,10 @@ PrivateData = @{ LicenseUri = "https://www.apache.org/licenses/LICENSE-2.0.html" # Release notes for this particular version of the module - ReleaseNotes = 'https://github.com/pester/Pester/releases/tag/4.4.3-beta1' + ReleaseNotes = 'https://github.com/pester/Pester/releases/tag/4.4.3' # Prerelease string of this module - Prerelease = 'beta1' + Prerelease = '' } } diff --git a/cleanUpBeforeBuild.ps1 b/cleanUpBeforeBuild.ps1 index d97e08f5e..495c17872 100644 --- a/cleanUpBeforeBuild.ps1 +++ b/cleanUpBeforeBuild.ps1 @@ -8,20 +8,22 @@ # each package then decides what will be part of it $buildDir = "$PSScriptRoot\build" +$ErrorActionPreference = 'Stop' + if (Test-Path $buildDir) { Write-Verbose "Removing build dir" - Remove-Item $buildDir -Recurse -Force -Confirm:$false -Verbose + Remove-Item $buildDir -Recurse -Force -Confirm:$false -Verbose -ErrorAction 'Stop' } if (Test-Path "$PSScriptRoot\Examples") { Write-Verbose "Removing all examples" - Remove-Item "$PSScriptRoot\Examples" -Recurse -Force -Confirm:$false -Verbose + Remove-Item "$PSScriptRoot\Examples" -Recurse -Force -Confirm:$false -Verbose -ErrorAction 'Stop' } if (Test-Path "$PSScriptRoot\doc") { Write-Verbose "Removing docs" - Remove-Item "$PSScriptRoot\doc" -Recurse -Force -Confirm:$false -Verbose + Remove-Item "$PSScriptRoot\doc" -Recurse -Force -Confirm:$false -Verbose -ErrorAction 'Stop' } Write-Verbose "Removing all Test Files" -Get-ChildItem $PSScriptRoot -Recurse -Filter *.Tests.ps1 | Remove-Item -Force -Verbose +Get-ChildItem $PSScriptRoot -Recurse -Filter *.Tests.ps1 | Remove-Item -Force -Verbose -ErrorAction 'Stop' diff --git a/release.ps1 b/release.ps1 new file mode 100644 index 000000000..48f0b3a18 --- /dev/null +++ b/release.ps1 @@ -0,0 +1,32 @@ +# build should provide '%system.teamcity.build.checkoutDir%' +param ( + [Parameter(Mandatory)] + [String] $CertificateThumbprint, + [Parameter(Mandatory)] + [String] $NugetApiKey, + [String] $ChocolateyApiKey, + [Parameter(Mandatory)] + [String] $PsGalleryApiKey + + + +) + +$ErrorActionPreference = 'Stop' +# run this in seperate instance otherwise Gherkin.dll is loaded and +$process = Start-Process powershell -ArgumentList "-c", ".\testRelease.ps1 -LocalBuild" -NoNewWindow -Wait -PassThru + +if ($process.ExitCode -ne 0) { + throw "Testing failed with exit code $($process.ExitCode)." +} + +.\getNugetExe.ps1 +.\cleanUpBeforeBuild.ps1 +.\signModule.ps1 -Thumbprint $CertificateThumbprint +.\buildNugetPackage.ps1 +.\buildPSGalleryPackage.ps1 + + +# .\publishPSGalleryPackage.ps1 $PsGalleryApiKey +# publish nuget +# publish chocolatey diff --git a/signModule.ps1 b/signModule.ps1 index 6e4aea56e..8c1305275 100644 --- a/signModule.ps1 +++ b/signModule.ps1 @@ -1,6 +1,8 @@ +param($Thumbprint) $ErrorActionPreference = 'Stop' -$cert = Get-ChildItem Cert:\CurrentUser\My | - Where Thumbprint -eq "CC1168BAFCDA3B1A5E532DA87E80A4DD69BCAEB1" + +$cert = Get-ChildItem Cert:\CurrentUser\My | + where Thumbprint -eq $Thumbprint if ($null -eq $cert) { throw "No certificate was found." diff --git a/testRelease.ps1 b/testRelease.ps1 new file mode 100644 index 000000000..820a4aa08 --- /dev/null +++ b/testRelease.ps1 @@ -0,0 +1,45 @@ +param( + [switch] $LocalBuild +) + +$ErrorActionPreference = 'Stop' + +$psd1 = Join-Path $PSScriptRoot Pester.psd1 + +Get-Module Pester | Remove-Module +Import-Module $psd1 -ErrorAction Stop + +$xml = Join-Path $PSScriptRoot Test.Version.xml +$result = Invoke-Pester -Path $PSScriptRoot -Tag VersionChecks, StyleRules -OutputFile $xml -OutputFormat NUnitXml -PassThru -Strict -ErrorAction Stop + +if ($LocalBuild) { + # when I build release locally I don't want to + # think about removing the xml all the time + Remove-Item $xml +} + +if ($result.TotalCount -lt 1) +{ + $m = "No tests were run." + + if ($LocalBuild) { + $m + exit 9999 + } + else { + throw $m + } +} + +if ($result.FailedCount -gt 0) +{ + $m = "$($result.FailedCount) tests did not pass." + if ($LocalBuild) { + $m + exit $result.FailedCount + } + else + { + throw $m + } +}