-
-
Save guneysus/7a7334bd23ff298b607978ab9f106608 to your computer and use it in GitHub Desktop.
Example script for publishing a PowerShell module to the NuGet GitHub Package Registry
This file contains hidden or 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
<# -- | |
Register the GitHub Package Registry | |
-- #> | |
$username = '<github-username>' | |
$token = '<github-personal-token>' | |
$sourceName = 'GitHub' | |
$source = "https://nuget.pkg.github.com/$username/index.json" | |
# add the github package registry as a nuget source | |
nuget sources Add -Name $sourceName -Source $source -UserName $username -Password $token | |
# register the github package registry as a powershell repository | |
$creds = New-Object System.Management.Automation.PSCredential -ArgumentList $username, (ConvertTo-SecureString -AsPlainText $token -Force) | |
Register-PSRepository -Name $sourceName -SourceLocation $source -PublishLocation $source -Credential $creds | |
<# -- | |
Publish PowerShell module | |
-- #> | |
$module = '<module-name>' | |
$version = '<module-version>' | |
$apiKey = 'n/a' # keep this as n/a! | |
Publish-Module -Name $module -Repository $sourceName -RequiredVersion $version -Credential $creds -Force -NuGetApiKey $apiKey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment