forked from cdroulers/awesome-sql-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish.ps1
70 lines (61 loc) · 1.9 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<#
.PARAMETER KeyFile
Path to NuGet key file.
DEFAULT: ".\.nuget\key.txt"
.PARAMETER Version
Which version to push (will use it to list packages in the PackagesPath)
.PARAMETER NuGetPath
The path to the nuget.exe executable.
DEFAULT: ".\.nuget\nuget.exe"
.PARAMETER PackagesPath
The path to the built packages folder.
DEFAULT: ".\builds\nuget"
#>
PARAM(
[String]
$KeyFile = (Resolve-Path ".\.nuget\key.txt"),
[String]
$Version,
[String]
$NuGetPath = (Resolve-Path ".\.nuget\nuget.exe"),
[String]
$PackagesPath = (Resolve-Path ".\builds\nuget")
)
if (-not (Test-Path $KeyFile))
{
throw "Could not find the NuGet access key at $KeyFile. Specify your file!!!"
}
if (-not (Test-Path $NuGetPath))
{
throw "Nuget.exe not found at $NuGetPath";
}
if (-not (Test-Path $PackagesPath))
{
throw "Packages folder not found at $PackagesPath";
}
pushd $PackagesPath
# get our secret key. This is not in the repository.
$key = Get-Content $KeyFile
# Find all the packages and display them for confirmation
$packages = dir "*.$version.nupkg"
"Packages to upload: "
$packages | % { write-host $_.Name }
# Ensure we haven't run this by accident.
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Uploads the packages."
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Does not upload the packages."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($no, $yes)
$result = $host.ui.PromptForChoice("Upload packages", "Do you want to upload the NuGet packages to the NuGet server?", $options, 0)
if ($result -eq 0)
{
"Upload aborted"
}
elseif($result -eq 1)
{
$packages | % {
$package = $_.Name
write-host "Uploading $package"
& $NuGetPath push $package $key
write-host ""
}
}
popd