Created
January 19, 2017 15:44
-
-
Save markwragg/4d243b4ff57e0092800df5e9f1d401ff to your computer and use it in GitHub Desktop.
The start of a build script which publishes the module to PSGallery having incremented the version number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Required module - BuildHelpers: https://github.com/RamblingCookieMonster/BuildHelpers | |
[cmdletbinding()] | |
Param( | |
[string]$PSGalleryKey = (Import-Clixml PSGalleryKey.xml), #So I don't put it on the internet. | |
[string]$Module, | |
[string]$Version, | |
[switch]$Publish | |
) | |
$ModuleData = (Get-Module $Module) | |
If (!$Version) { | |
Try { | |
$Version = (Get-NextPSGalleryVersion $Module) | |
} Catch { | |
Write-Error "No version specified and could not determine automatically." -Category ConnectionError | |
Break | |
} | |
} | |
If ($Version -and $Version -ne '0.0.1') { | |
Try { | |
Update-ModuleManifest -Path ($ModuleData.Path) -ModuleVersion $Version | |
Write-Verbose "Module manifest updated with -ModuleVersion $Version" | |
If ($Publish) { | |
Try { | |
Publish-Module -Name $Module -NuGetApiKey $PSGalleryKey | |
Write-Verbose "Published $Module to PSGallery" | |
} Catch { | |
Write-Error "Could not publish to PSGallery." -Category ConnectionError | |
} | |
} | |
} Catch { | |
Write-Error "Could not update module manifest." -Category ConnectionError | |
} | |
}Else{ | |
Write-Error "No version specified." -Category InvalidArgument | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment