diff --git a/appveyor.yml b/appveyor.yml index 58d179ca..699b1c0d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,9 +5,6 @@ # version format version: '{build}' -# do not build on tags (GitHub and BitBucket) -skip_tags: true - #---------------------------------# # environment configuration # #---------------------------------# @@ -15,6 +12,11 @@ skip_tags: true # build worker image (VM template) image: Visual Studio 2017 +# environment variables +environment: + NUGET_API_KEY: + secure: 8PQpunzi9jRouQhHpoxy7d1vsM58SmWeiDRab2B8y8/BFWCBDxHeVb+TxBWrgFHJ + #---------------------------------# # build configuration # #---------------------------------# diff --git a/build/build.ps1 b/build/build.ps1 index 5d1f9bc1..6ffddc5d 100644 --- a/build/build.ps1 +++ b/build/build.ps1 @@ -6,7 +6,9 @@ Write-Host "build: dotnet cli v$(dotnet --version)" Push-Location $PSScriptRoot\.. -if (Test-Path .\artifacts) { +# Clean artifacts +if (Test-Path .\artifacts) +{ Write-Host "build: Cleaning .\artifacts" Remove-Item .\artifacts -Force -Recurse } @@ -18,26 +20,35 @@ $suffix = @{ $true = ""; $false = "$branch-$revision"}[$branch -eq "master" -and Write-Host "build: Version suffix is '$suffix'" -foreach ($src in Get-ChildItem src/*) { - Push-Location $src +# Build and pack +foreach ($source in Get-ChildItem .\src\*) +{ + Push-Location $source - Write-Host "build: Packaging project in $src" + Write-Host "build: Packaging project in $source" if ($suffix -eq "") { & dotnet build -c Release & dotnet pack -c Release --include-symbols -o ..\..\artifacts --no-build } - else { + else + { & dotnet build -c Release --version-suffix=$suffix & dotnet pack -c Release --include-symbols -o ..\..\artifacts --version-suffix=$suffix --no-build } - if ($LASTEXITCODE -ne 0) { exit 1 } + + if ($LASTEXITCODE -ne 0) + { + exit 1 + } Pop-Location } -foreach ($test in Get-ChildItem test/*Tests) { +# Test +foreach ($test in Get-ChildItem test/*Tests) +{ Push-Location $test Write-Host "build: Testing project in $test" @@ -48,4 +59,19 @@ foreach ($test in Get-ChildItem test/*Tests) { Pop-Location } +# Push +if ($env:APPVEYOR_REPO_TAG -eq "true") +{ + Write-Host "build: push package to www.nuget.org" + + Push-Location .\artifacts + + foreach ($package in Get-ChildItem *.nupkg -Exclude *.symbols.nupkg) + { + & dotnet nuget push $package --source https://www.nuget.org/api/v2/package --api-key $NUGET_API_KEY + } + + Pop-Location +} + Pop-Location