-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpublish.ps1
52 lines (38 loc) · 1.58 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
param (
[string]$NuGetPath = "C:\ProgramData\Microsoft\Windows\PowerShell\PowerShellGet",
[string]$NuGetApiKey
)
if (!(Test-Path -Path "$NuGetPath\nuget.exe")) {
if (!(Test-Path -Path $NuGetPath)) {
New-Item -ItemType "Directory" -Path $NuGetPath -force -verbose | Out-Null
}
Write-Output "Downloading the NuGet Executable..."
(New-Object System.Net.WebClient).DownloadFile("https://nuget.org/nuget.exe", "$NuGetPath\nuget.exe")
}
# find the current published version
try {
$pver = [version](Find-Module DotEnv | Select-Object -expand version)
}
catch {
$pver = [version]"0.0.0.0"
}
# find the current manifest version
$mver = (Import-PowerShellDataFile .\Module\DotEnv\DotEnv.psd1).ModuleVersion
if ($mver -gt $pver) {
Write-Output "Version has incremented. Publishing to PSGallery"
Write-Output "Installing the NuGet Package Provider..."
Install-PackageProvider -Name "NuGet" -MinimumVersion "2.8.5.201" -Force -Verbose
Write-Output "Trusting the PSGallery Repository..."
Set-PSRepository -Name "PSGallery" -InstallationPolicy "Trusted" -Verbose
# TODO: gather release notes, publish with notes
Write-Output "Publishing the DotEnv Module..."
Publish-Module -Path "./Module/DotEnv" -NuGetApiKey $NuGetApiKey -Verbose -force
git config --global user.email "[email protected]"
git config --global user.name "Octopus - deploy.d.evops.co"
git tag -a "$mver" -m "Version $mver release"
git push --tags
}
else {
Write-Output "Version not incremented, declining to publish"
}
exit 0 # so Octopus exits correctly