-
Notifications
You must be signed in to change notification settings - Fork 8
/
publishme.ps1
42 lines (35 loc) · 1.43 KB
/
publishme.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
[CmdletBinding()]
Param(
[string]$Version = $null,
[string]$NuGetApiKey = $env:PSNugetKey,
[switch]$Confirm = $false,
[switch]$WhatIf = $false
)
Copy-Item $PSScriptRoot/readme.md $PSScriptRoot/cd-extras/about_Cd-Extras.help.txt
$manifest = Import-PowerShellDataFile "$PSScriptRoot/cd-extras/cd-extras.psd1"
If ([String]::IsNullOrEmpty($Version)) {
$Version = $manifest.ModuleVersion
}
Else {
If ($Version[0] -Eq 'v') {
$Version = [regex]::Replace($Version, '^v', "")
}
}
$outputDirectory = "$PSScriptRoot/out/$Version"
$null = Remove-Item -Force -Recurse $outputDirectory -ErrorAction Ignore
$null = New-Item -Type Directory $outputDirectory
$null = Copy-Item -Recurse "$PSScriptRoot/cd-extras" "$outputDirectory/cd-extras"
$releaseNotes = (Get-Content -Raw CHANGELOG.md).Split('##') | select -Skip 1 -f 1 | % { $_.Trim() }
If ($manifest.ModuleVersion -ne $Version) {
Write-Warning "Version $Version specified on commandline, but manifest contains $($manifest.ModuleVersion)."
Write-Warning "Preferring $Version from commandline."
Update-ModuleManifest -Path "$outputDirectory/cd-extras/cd-extras.psd1" -ModuleVersion $Version
Update-ModuleManifest -Path "$outputDirectory/cd-extras/cd-extras.psd1" -ReleaseNotes $releaseNotes
}
$publishParameters = @{
Path = "$outputDirectory/cd-extras"
NuGetApiKey = $NugetAPIKey
Repository = "PSGallery"
WhatIf = $WhatIf
}
Publish-Module -Confirm:$Confirm @publishParameters