-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -329,3 +329,6 @@ ASALocalRun/ | |
|
||
# MFractors (Xamarin productivity tool) working folder | ||
.mfractor/ | ||
|
||
**/*.key | ||
nuget/archive/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Configuration | ||
$scriptDir = $PSScriptRoot | ||
$rootDir = Join-Path $scriptDir ".." | ||
$archive = Join-Path $scriptDir archive | ||
$corePackage = "TheSadRogue.Primitives" | ||
$dependentPackages = @("TheSadRogue.Primitives.MonoGame", "TheSadRogue.Primitives.SFML") | ||
$nugetKeyPath = Join-Path $scriptDir "nuget.key" | ||
|
||
# Delete any NuGet packages not moved to archive | ||
Write-Output "Removing old nupkg files" | ||
Remove-Item "$scriptDir\*.nupkg","$scriptDir\*.snupkg" -Force | ||
|
||
# Make sure archive directory exists | ||
if(!(Test-Path $archive)) | ||
{ | ||
New-Item -Path $archive -ItemType Directory -Force | Out-Null | ||
} | ||
|
||
# Build core package | ||
Write-Output "Building $corePackage Debug and Release" | ||
$output = Invoke-Expression "dotnet build $rootDir\$corePackage\$corePackage.csproj -c Debug --no-cache"; if ($LASTEXITCODE -ne 0) { Write-Error "Failed"; Write-Output $output; throw } | ||
$output = Invoke-Expression "dotnet build $rootDir\$corePackage\$corePackage.csproj -c Release --no-cache"; if ($LASTEXITCODE -ne 0) { Write-Error "Failed"; Write-Output $output; throw } | ||
|
||
# Find the version we're using | ||
$version = (Get-Content $rootDir\$corePackage\$corePackage.csproj | Select-String "<Version>(.*)<").Matches[0].Groups[1].Value | ||
$nugetKey = Get-Content $nugetKeyPath | ||
Write-Output "Target $coreProjectVersion version is $version" | ||
|
||
# Push packages to nuget | ||
Write-Output "Pushing $corePackage packages" | ||
$corePackages = Get-ChildItem "$corePackage.*.nupkg" | Select-Object -ExpandProperty Name | ||
|
||
foreach ($package in $corePackages) { | ||
$output = Invoke-Expression "dotnet nuget push `"$package`" -s nuget.org -k $nugetKey --skip-duplicate"; if ($LASTEXITCODE -ne 0) { Write-Error "Failed"; Write-Output $output; throw } | ||
} | ||
|
||
Write-Output "Query NuGet for 10 minutes to find the new package" | ||
|
||
$timeout = New-TimeSpan -Minutes 10 | ||
$timer = [Diagnostics.StopWatch]::StartNew() | ||
[Boolean]$foundPackage = $false | ||
|
||
# Loop searching for the new SadConsole package | ||
while ($timer.elapsed -lt $timeout){ | ||
|
||
$existingVersions = (Invoke-WebRequest "https://api-v2v3search-0.nuget.org/query?q=PackageId:$corePackage&prerelease=true").Content | ConvertFrom-Json | ||
|
||
if ($existingVersions.totalHits -eq 0) { | ||
throw "Unable to get any results from NuGet" | ||
} | ||
|
||
if ($null -eq ($existingVersions.data.versions | Where-Object version -eq $version)) { | ||
Write-Output "Waiting 30 seconds to retry..." | ||
Start-Sleep -Seconds 30 | ||
|
||
} | ||
else { | ||
Write-Output "Found package. Waiting 1 extra minute to let things settle" | ||
$foundPackage = $true | ||
Start-Sleep -Seconds 60 | ||
break | ||
} | ||
} | ||
|
||
# Found the core package, start building and pushing the other packages | ||
if ($foundPackage){ | ||
|
||
foreach ($project in $dependentPackages) { | ||
# Build package | ||
Write-Output "Building $project Debug and Release" | ||
$output = Invoke-Expression "dotnet build $rootDir\$project\$project.csproj -c Debug -p:UseProjectReferences=false --no-cache"; if ($LASTEXITCODE -ne 0) { Write-Error "Failed"; Write-Output $output; throw } | ||
$output = Invoke-Expression "dotnet build $rootDir\$project\$project.csproj -c Release -p:UseProjectReferences=false --no-cache"; if ($LASTEXITCODE -ne 0) { Write-Error "Failed"; Write-Output $output; throw } | ||
|
||
# Push packages to nuget | ||
Write-Output "Pushing $project packages" | ||
$packages = Get-ChildItem "$project*.nupkg" | Select-Object -ExpandProperty Name | ||
|
||
foreach ($package in $packages) { | ||
$output = Invoke-Expression "dotnet nuget push `"$package`" -s nuget.org -k $nugetKey --skip-duplicate"; if ($LASTEXITCODE -ne 0) { Write-Error "Failed"; Write-Output $output; throw } | ||
} | ||
} | ||
|
||
# Archive the packages | ||
Move-Item "$scriptDir\*.nupkg","$scriptDir\*.snupkg" $archive -force | ||
} else { | ||
Write-Error "$corePackage didn't appear on NuGet within 10 minutes." | ||
} |
This file was deleted.
Oops, something went wrong.