-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpublish.ps1
More file actions
58 lines (49 loc) · 1.88 KB
/
publish.ps1
File metadata and controls
58 lines (49 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Publish NuGet packages to nuget.org
# Usage: .\publish.ps1 -ApiKey YOUR_API_KEY [-Source https://api.nuget.org/v3/index.json]
param(
[Parameter(Mandatory=$true)]
[string]$ApiKey,
[string]$Source = "https://api.nuget.org/v3/index.json",
[string]$PackageDir = ".\nupkgs"
)
$ErrorActionPreference = "Stop"
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " DataFlow.NET NuGet Publisher" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "Source: $Source"
Write-Host "Packages: $PackageDir"
Write-Host ""
# Check if packages exist
$packages = Get-ChildItem $PackageDir -Filter *.nupkg -ErrorAction SilentlyContinue
if (-not $packages) {
Write-Host "No packages found in $PackageDir. Run .\pack.ps1 first." -ForegroundColor Red
exit 1
}
Write-Host "Found $($packages.Count) package(s) to publish:" -ForegroundColor Yellow
$packages | ForEach-Object { Write-Host " - $($_.Name)" -ForegroundColor White }
Write-Host ""
# Confirm
$confirm = Read-Host "Publish these packages to $Source? (y/N)"
if ($confirm -ne "y" -and $confirm -ne "Y") {
Write-Host "Aborted." -ForegroundColor Yellow
exit 0
}
# Publish each package
$success = 0
$failed = 0
foreach ($pkg in $packages) {
Write-Host "Publishing $($pkg.Name)..." -ForegroundColor Yellow
dotnet nuget push $pkg.FullName --api-key $ApiKey --source $Source --skip-duplicate
if ($LASTEXITCODE -eq 0) {
Write-Host " Published!" -ForegroundColor Green
$success++
} else {
Write-Host " Failed!" -ForegroundColor Red
$failed++
}
}
Write-Host ""
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " Results: $success succeeded, $failed failed" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan