Skip to content

Commit

Permalink
chore: push NuGet package on tag (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
FantasticFiasco authored Feb 1, 2018
1 parent df4829b commit 50c01a9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 10 deletions.
8 changes: 5 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
# version format
version: '{build}'

# do not build on tags (GitHub and BitBucket)
skip_tags: true

#---------------------------------#
# environment configuration #
#---------------------------------#

# build worker image (VM template)
image: Visual Studio 2017

# environment variables
environment:
NUGET_API_KEY:
secure: 8PQpunzi9jRouQhHpoxy7d1vsM58SmWeiDRab2B8y8/BFWCBDxHeVb+TxBWrgFHJ

#---------------------------------#
# build configuration #
#---------------------------------#
Expand Down
40 changes: 33 additions & 7 deletions build/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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"
Expand All @@ -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

0 comments on commit 50c01a9

Please sign in to comment.