From 2d2b8016d113ac44eeaa0ac2df63c74d8d1db294 Mon Sep 17 00:00:00 2001 From: Marko Stanojevic Date: Tue, 10 Feb 2026 21:12:30 +0000 Subject: [PATCH 1/2] Add task to create and publish a NuGet package for the module --- PSScriptModule.build.ps1 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/PSScriptModule.build.ps1 b/PSScriptModule.build.ps1 index 002438d..d89aaa3 100644 --- a/PSScriptModule.build.ps1 +++ b/PSScriptModule.build.ps1 @@ -215,6 +215,34 @@ task Build Clean, { Build-Module @requestParam } +# Synopsis: Create a NuGet package for the module +task Package { + $packageOutputPath = Join-Path -Path $buildPath -ChildPath 'package' + if (!(Test-Path $packageOutputPath)) { + [void] (New-Item -Path $packageOutputPath -ItemType Directory -Force) + } + + $requestParam = @{ + Name = "$($moduleName)_local_feed" + SourceLocation = $packageOutputPath + PublishLocation = $packageOutputPath + InstallationPolicy = 'Trusted' + ErrorAction = 'Stop' + } + [void] (Register-PSRepository @requestParam) + + $requestParam = @{ + Path = (Join-Path -Path $buildPath -ChildPath "out/$moduleName") + Repository = "$($moduleName)_local_feed" + NuGetApiKey = 'ABC123' + ErrorAction = 'Stop' + } + [void] (Publish-Module @requestParam) + + [void] (Unregister-PSRepository -Name "$($moduleName)_local_feed") + +} + # Synopsis: Publish the module to PSGallery task Publish -If ($NugetApiKey) { $requestParam = @{ From 61afc15ea6188e9db604561c7939cecfa32be6a0 Mon Sep 17 00:00:00 2001 From: Marko Stanojevic Date: Tue, 10 Feb 2026 21:16:08 +0000 Subject: [PATCH 2/2] Add steps to publish and upload NuGet package to GitHub Release --- .github/actions/ps-release/action.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/actions/ps-release/action.yml b/.github/actions/ps-release/action.yml index 2c9d3b0..ba498d8 100644 --- a/.github/actions/ps-release/action.yml +++ b/.github/actions/ps-release/action.yml @@ -66,3 +66,18 @@ runs: Set-StrictMode -Version Latest [void] (Import-Module InvokeBuild) Invoke-Build -NugetApiKey ${{ env.PSGALLERY_API_KEY }} -Task Publish + + - name: Publish build package to Github Release + shell: pwsh + run: | + Set-StrictMode -Version Latest + [void] (Import-Module InvokeBuild) + Invoke-Build -Task Package + + - name: Upload build package to Github Release + uses: actions/upload-release-asset@v1 + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./build/package/*.nupkg + asset_name: ${{ github.event.repository.name }}-v${{ inputs.release-version }}.nupkg + asset_content_type: application/octet-stream