-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpublish.ps1
48 lines (40 loc) · 1.37 KB
/
publish.ps1
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
param(
[Parameter(Mandatory=$false)]
[string]$list = "pack-list.txt"
,
[Parameter(Mandatory=$false)]
[string]$nugetFolder = "nupkg"
,
[Parameter(Mandatory=$false)]
[string]$nugetSource = "https://api.nuget.org/v3/index.json"
,
[Parameter(Mandatory=$true)]
[string]$nugetApiKey
)
Write-Host "Publishing NuGet from projects..."
$fileExists = [System.IO.File]::Exists($list)
if (-not $fileExists)
{
Write-Host "File '${list}' does not exists, can't continue publishing."
Write-Host "ERROR!";
exit -1;
}
$lines = [System.IO.File]::ReadLines($list) | ? {$_.trim() -ne "" }
if ($lines.Length -eq 0) {
Write-Host "No project(s) listed in file '${list}', can't continue publishing."
Write-Host "ERROR!";
exit -1;
}
$lines | ForEach-Object {
$source = $_
$packageSourceFolder = "$($source)/$($nugetFolder)"
Write-Host "`n`n`n"
Write-Host "Project : $(${source})"
Write-Host "Package folder: $(${packageSourceFolder})"
Write-Host "---"
# as *.nupkg does not works (in Github actions)
# dotnet nuget push $packageSourceFolder/*.nupkg -s $nugetSource -k $nugetApiKey --skip-duplicate 2>&1 | Write-Host
$nupkgFileName = @(gci $packageSourceFolder/*.nupkg)[0].Name
dotnet nuget push $packageSourceFolder/$nupkgFileName -s $nugetSource -k $nugetApiKey --skip-duplicate 2>&1 | Write-Host
if ($LASTEXITCODE -ne 0) { Write-Host "ERROR!"; exit -1; }
}