Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rbjoergensen/publish-pwsh-module
How to build a PowerShell module and publish it to Azure DevOps and GitHub package feeds.
https://github.com/rbjoergensen/publish-pwsh-module
azure-devops devops powershell
Last synced: 16 days ago
JSON representation
How to build a PowerShell module and publish it to Azure DevOps and GitHub package feeds.
- Host: GitHub
- URL: https://github.com/rbjoergensen/publish-pwsh-module
- Owner: rbjoergensen
- License: mit
- Created: 2022-04-21T21:12:35.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-26T22:23:42.000Z (over 2 years ago)
- Last Synced: 2024-07-29T17:04:40.858Z (3 months ago)
- Topics: azure-devops, devops, powershell
- Language: PowerShell
- Homepage:
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Build and publish PowerShell modules
## Build and Publish using the Azure DevOps template
In this example I'm using the template from an external source on GitHub instead of the one local to the repository.
I'm specifying the name I want the package to have and the feed in my current organization that i want to publish to.
The path to the module is expected to have file called `RootModule.psm1` with the same content as in the example and a folder called `Public`.
The public folder should contain a file for each function named exactly after the function inside.
This is so that the build script can automatically include each function in the manifest.
``` yaml
trigger:
branches:
include:
- main
paths:
include:
- modules/Example/**resources:
repositories:
- repository: templates
type: github
name: rbjoergensen/azure-devops-templatesstages:
- template: /powershell/build.yml@templates
parameters:
name: MyTestPackage
path: $(System.DefaultWorkingDirectory)/modules/Example
feed: PowerShell
author: github.com/rbjoergensen
company: CallOfTheVoid
descritpion: An example module
```
## Installing a package from an Azure DevOps feed
PowerShell doesn't support v3 as of writing.
``` powershell
$token = ""$feed = "https://pkgs.dev.azure.com/callofthevoid/_packaging/Powershell/nuget/v2"
$source = "CotvPowerShell"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$credential = New-Object System.Management.Automation.PSCredential("whatever",
($token | ConvertTo-SecureString -AsPlainText -Force))Register-PackageSource `
-Name $source `
-ProviderName PowerShellGet `
-Location $feed `
-Trusted `
-Credential $credential `
-ForceInstall-Module `
-Name "" `
-Repository $source `
-Force `
-Credential $credential
```
## Creating a personal access token(PAT)
To create a personal access token go to your organization at this link.
https://dev.azure.com/myorganization/_usersSettings/tokens.Just replace the organization with the name of your own. Click on `+ New token` and give it the scope `Packaging: Read`.