Skip to content

fix(build): publish from artefact path to include vendored deps#60

Merged
jakehildreth merged 2 commits into
mainfrom
fix/publish-from-artefact-path
May 10, 2026
Merged

fix(build): publish from artefact path to include vendored deps#60
jakehildreth merged 2 commits into
mainfrom
fix/publish-from-artefact-path

Conversation

@jakehildreth
Copy link
Copy Markdown
Owner

Problem

When publishing via New-ConfigurationPublish inside the Build-Module {} scriptblock, PSPublishModule calls Publish-Module -Name Locksmith2 which resolves the module from $PSModulePath. That copy is written before the post-build vendoring step, so PSWriteHTML and PSCertutil are never included in what gets uploaded to PSGallery.

Solution

  • Removed New-ConfigurationPublish from the Build-Module {} scriptblock entirely
  • Extracted all post-build logic into Build/Invoke-LS2PostBuildPublish.ps1, a proper advanced function with SupportsShouldProcess and comment-based help
  • Build-Module.ps1 now dot-sources and calls Invoke-LS2PostBuildPublish after Build-Module {} completes, so Publish-Module -Path $artefactRoot sees the fully vendored Modules\ tree
  • Added colored [i]/[>]/[+]/[x] output matching PSPublishModule's style

Tests

Added Tests/Build/Build-Module.Tests.ps1 with 12 unit tests covering:

  • vendoring always runs regardless of publish flag
  • Publish-Module is not called when -PublishToPSGallery is absent
  • -Path (not -Name) is passed to Publish-Module
  • API key passed correctly via direct string or file path
  • error written when publish requested but no key provided

CI Impact

No changes to publish.yml required — the workflow already passes $env:PSGALLERY_API_KEY via -PSGalleryAPIKey and Build-Module.ps1 forwards it through.

- Remove New-ConfigurationPublish from Build-Module {} scriptblock; PSPublishModule
  resolves -Name from PSModulePath (pre-vendoring) so PSWriteHTML/PSCertutil were absent
- Extract post-build logic into Build/Invoke-LS2PostBuildPublish.ps1 with
  SupportsShouldProcess and full cbh; calls Publish-Module -Path \
- Update Build-Module.ps1 to dot-source and call Invoke-LS2PostBuildPublish after
  Build-Module {} completes, ensuring vendored Modules\ tree is present at publish time
- Add Tests/Build/Build-Module.Tests.ps1 with 12 unit tests covering publish/no-publish,
  api key vs file path, NestedModules patching, and Save-Module invocations
- Replace plain Write-Host strings in Invoke-LS2PostBuildPublish.ps1 with
  colored [i]/[>]/[+]/[x] indicators matching PSPublishModule output style
- Print blank line before vendoring and publish sections for visual separation
- [>] yellow for in-progress, [+] green for success, [x] red for errors
@jakehildreth jakehildreth merged commit 83165f6 into main May 10, 2026
1 check passed
@jakehildreth jakehildreth deleted the fix/publish-from-artefact-path branch May 10, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant