Skip to content

Instantly share code, notes, and snippets.

@dotps1
Last active June 21, 2016 20:28
Show Gist options
  • Save dotps1/ac4dc34b111cecc3507e8c787c00e876 to your computer and use it in GitHub Desktop.
Save dotps1/ac4dc34b111cecc3507e8c787c00e876 to your computer and use it in GitHub Desktop.
Appveyor Build
# http://www.appveyor.com/docs/appveyor-yml
version: 1.4.{build}
os: WMF 5
skip_commits:
message: /updated readme.*/
install:
- ps: Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Confirm:$false -Force -ErrorAction Stop
- ps: Install-Module -Name Configuration, Pester, PSScriptAnalyzer -Confirm:$false -Force -ErrorAction SilentlyContinue
build: off
test_script:
- ps: . .\Invoke-AppveyorBuild.ps1
environment:
powershell_gallery_api_token:
secure: feZG1n6/I0hDzxw9VWtlUph94caZUYw3denU0TLudvgWX9cG/jkjDLOT8ixd02P4
notifications:
- provider: Slack
incoming_webhook:
secure: AbntoBWt4UaZffU0mBhQjuXCQAIegqF1NtTVdnFyinHHS23C+b/r4/lWGDzneboipU5R9/6ti/x1p1ceodafH5iv+il9EyS87/M8TaE3hf8=
#requires -Modules Configuration, Pester, PSScriptAnalyzer
try {
Set-Location -Path $env:APPVEYOR_BUILD_FOLDER -ErrorAction Stop
$timestamp = Get-Date -uformat "%Y%m%d-%H%M%S"
$resultsFile = "Results_${timestamp}.xml"
Import-Module -Name .\$env:APPVEYOR_PROJECT_NAME -Force -ErrorAction Stop
Invoke-Pester -Path '.\Tests' -OutputFormat NUnitXml -OutputFile ".\$resultsFile" -PassThru -ErrorAction Stop |
Export-Clixml -Path ".\Pester$resultsFile"
(New-Object -TypeName System.Net.WebClient).UploadFile(
"https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path -Path ".\$resultsFile")
)
[Int]$failures = Import-Clixml -Path ".\Pester$resultsFile" -ErrorAction Stop |
Select-Object -ExpandProperty FailedCount |
Measure-Object -Sum |
Select-Object -ExpandProperty Sum
if ($failures -gt 0) {
throw "Build failed."
} else {
# Publish to the PowerShell Gallery if the build is successful.
Update-Metadata -Path ".\${env:APPVEYOR_PROJECT_NAME}\${env:APPVEYOR_PROJECT_NAME}.psd1" -PropertyName ModuleVersion -Value $env:APPVEYOR_BUILD_VERSION -ErrorAction Stop
Update-Metadata -Path ".\${env:APPVEYOR_PROJECT_NAME}\${env:APPVEYOR_PROJECT_NAME}.psd1" -PropertyName ReleaseNotes -Value $env:APPVEYOR_REPO_COMMIT_MESSAGE -ErrorAction Stop
Publish-Module -Path .\$env:APPVEYOR_PROJECT_NAME -NuGetApiKey $env:POWERSHELL_GALLERY_API_TOKEN -Verbose -ErrorAction Stop
}
} catch {
throw $_
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment