Skip to content

🧪 Validate Process-PSModule publish fix (PSModule/Process-PSModule#529) - #63

Merged
MariusStorhaug merged 2 commits into
mainfrom
validate-publish-fix-pr529
Sep 2, 2026
Merged

🧪 Validate Process-PSModule publish fix (PSModule/Process-PSModule#529)#63
MariusStorhaug merged 2 commits into
mainfrom
validate-publish-fix-pr529

Conversation

@MariusStorhaug

Copy link
Copy Markdown
Owner

Validates the publish fix in PSModule/Process-PSModule#529 end to end, against a real publication.

Why

This repository reproduced the defect in PSModule/Process-PSModule#528: merging #62 to main failed at Publish-Module before any upload was attempted.

Failing run: 33596331743Publish-Module job

| Package with name 'MariusTestModule', version '0.4.13' could not be
| found in repository 'PSGallery'.
##[error]Process completed with exit code 1.

The existence probe in publish.ps1 treated an absent version as fatal, so every first-time publication of a new version failed.

What this changes

File Change
.github/workflows/Process-PSModule.yml caller ref @v8@copilot/fix-publish-module-error
src/functions/public/DateAndTime/Get-CurrentDateTime.ps1 documentation only — clarifies culture behaviour of the format presets

The source change exists only to give the pipeline something to release. It is comment-only: no executable code is touched.

Pointing the caller's uses: ref at the branch is sufficient, because the reusable workflow checks out its own actions at the resolved workflow commit rather than a floating tag:

- name: Checkout Process-PSModule
  uses: actions/checkout@...
  with:
    repository: ${{ job.workflow_repository }}
    ref: ${{ job.workflow_sha }}
    path: _wf

So _wf/.github/actions/Publish-PSModule/src/publish.ps1 resolves to the fixed file, with no vendoring or pinning workarounds.

Success criteria

Stage Expected
Plan resolves the next version
Publish-Module (this PR) prerelease publishes to the Gallery
Publish-Module (on merge) stable version publishes, no PackageNotFound failure
GitHub release created for the new version

The decisive signal is the merge publication: the probe must report "not found" without failing the job, then hand off to Publish-PSResource.

The starting point is clean — the failed run left the Gallery at 0.4.12 with no 0.4.13 release — so this is a direct before/after on the same version that previously failed.

Do not merge as-is

⚠️ The caller ref points at a branch, not a release tag. Once #529 merges and a v8 tag includes it, this must be reverted to @v8. Merging this ref permanently would pin the module to a feature branch.

Point the caller at PSModule/Process-PSModule#529
(copilot/fix-publish-module-error) to verify that publishing a version which
does not yet exist on the PowerShell Gallery succeeds.

Includes a documentation-only change to Get-CurrentDateTime so the pipeline
has a release to publish.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mariusstorhaug-shelly

Copy link
Copy Markdown

✅ New prerelease: PowerShell Gallery - MariusTestModule 0.4.13-validatepublishfixpr529001

@mariusstorhaug-shelly

Copy link
Copy Markdown

✅ New prerelease: GitHub - MariusTestModule v0.4.13-validatepublishfixpr529001

@mariusstorhaug-shelly

Copy link
Copy Markdown

✅ New prerelease: PowerShell Gallery - MariusTestModule 0.4.13-validatepublishfixpr529001

@mariusstorhaug-shelly

Copy link
Copy Markdown

✅ New prerelease: GitHub - MariusTestModule v0.4.13-validatepublishfixpr529001

@MariusStorhaug

Copy link
Copy Markdown
Owner Author

✅ Validation passed — the fix works end to end

Both branches of the Gallery existence probe confirmed on live infrastructure.

New version publishesPublish-Module, run 33597824748:

MariusTestModule 0.4.13-validatepublishfixpr529001 is not on the PowerShell Gallery yet.
##[notice]https://www.powershellgallery.com/packages/MariusTestModule/0.4.13-validatepublishfixpr529001
Gallery publishing complete.

Same 0.4.13 base version that failed in run 33596331743. Package verified live on the Gallery.

Resume path intactre-run of the same job, with the version now present:

##[notice]MariusTestModule 0.4.13-validatepublishfixpr529001 is already published to the PowerShell Gallery.

No re-upload, no conflict. This was the risk in narrowing the error filter, and it holds.

Note for anyone re-running this

The first run came back all-green with Publish-Module skipped — nothing published, so the fix was untested despite the green checkmark. An open PR with no labels resolves ReleaseType: None (AutoPatching applies on merge, not to the open PR). Adding prerelease produced the real publication.

Don't trust the overall run status here; confirm Publish-Module actually ran.

Still a draft on purpose

⚠️ The caller is pinned to a branch. This reverts to @v8 once PSModule/Process-PSModule#529 merges and lands in a tag. Full write-up on issue #528.

MariusStorhaug added a commit to PSModule/Process-PSModule that referenced this pull request Sep 2, 2026
A module version that has never been published to the PowerShell Gallery
can now be published. Any first release, and every subsequent new
version, previously failed the Publish-Module stage before the upload
was attempted.

## Fixed: New module versions publish to the PowerShell Gallery

Publishing a version that is not yet on the PowerShell Gallery now
succeeds. The stage checks whether the version already exists so an
interrupted run can resume, and treats an absent version as the expected
result for a new release rather than an error.

Before this change the Publish-Module job failed with the following, and
no module was ever uploaded:

```text
Find-PSResource: Package with name 'MyModule', version '1.3.1' could not be found in repository 'PSGallery'.
Error: Process completed with exit code 1.
```

No repository configuration changes are needed. A workflow run that
previously failed at this point succeeds on re-run.

Resuming an interrupted publication is unchanged: when the version is
already on the Gallery, the run skips the upload and continues to GitHub
release creation.

---
<details>
<summary>Technical details</summary>

- `.github/actions/Publish-PSModule/src/publish.ps1` — the Gallery
existence probe in the `Publish to PSGallery` region ran
`Find-PSResource` with `-ErrorAction Stop`.
`Microsoft.PowerShell.PSResourceGet` raises
`PackageNotFound,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource`
when the requested version does not exist, which `-ErrorAction Stop`
turns into a throw, so the probe made a missing version fatal instead of
returning `$null`. The probe now keeps `-ErrorAction Stop` and catches
only `PackageNotFound`, treating that one error as 'not yet published'
and letting the `if ($publishedPackage)` branch decide the outcome.
Every other error stays fatal, so a transient Gallery failure cannot be
misread as 'version absent' and cause a re-upload of a version that
already exists.
- The probe was introduced in #512 to make
Gallery publication idempotent for the default-branch push release path.
That path replaced a `try`/`catch` around `Publish-PSResource`, which is
why the regression reached `main` without an existing test catching it.
-
`.github/actions/Publish-PSModule/tests/Publish-PSModule.Recovery.Tests.ps1`
— the harness could not observe whether publication happened, so its
assertions were vacuous: `Publish-PSResource` was shimmed to set
`$script:publishInvoked`, but `publish.ps1` runs in its own scope via
`&`, so the flag never propagated and stayed `$false` regardless.
Replaced with a hashtable captured by `GetNewClosure()`, which is shared
by reference. A second variant wrote a marker file under
`$env:GITHUB_WORKSPACE`; that is process-wide and races between parallel
Pester runspaces, so the marker could land in another test file's
`TestDrive`. The not-found shim also used
`$PSCmdlet.ThrowTerminatingError(...)`, which ignores `-ErrorAction` and
therefore threw under both `Stop` and `SilentlyContinue` — unable to
distinguish the fix from the defect. It now uses `Write-Error` with the
real `PackageNotFound` error ID, matching how the cmdlet actually
behaves. Added a case asserting a non-`PackageNotFound` lookup failure
stays fatal and does not publish. Each test was verified to fail against
the specific defect it guards.
-
`.github/actions/Release-PSModule/tests/Release-PSModule.WhatIf.Tests.ps1`
and `Publish-PSModule.Recovery.Tests.ps1` — shim teardown used
`Remove-Item -Path function:global:X`. `Set-Item` accepts that path and
creates `X` in the global scope, but `Remove-Item` and `Get-Item` do not
resolve it back, and fail silently rather than erroring, so the cleanup
was a no-op. The shims survived `AfterAll` and shadowed the real
commands for later test files, which is what made `Test-Actions` fail
with `A parameter cannot be found that matches parameter name
'Prerelease'` in `Get-NextPrereleaseNumber`. Teardown now removes by
name.
- Validated end to end in `MariusStorhaug/MariusTestModule` ([PR
#63](MariusStorhaug/MariusTestModule#63)) with
the caller pointed at this branch. A new version published successfully
([run
33597824748](https://github.com/MariusStorhaug/MariusTestModule/actions/runs/33597824748/job/100145585604)),
and re-running the same job with the version present skipped the upload
via the resume path
([re-run](https://github.com/MariusStorhaug/MariusTestModule/actions/runs/33597824748/job/100146802704)).
Both branches of the probe are confirmed against the live Gallery.
- Out of scope, found while reproducing: a `workflow_dispatch` on the
default branch resolves no associated pull request, because pull request
association in `.github/actions/Get-PSModuleSettings/src/main.ps1` is
gated on `$isPush`. A manual recovery run therefore discards the merged
pull request's version label and silently resolves a Patch bump. This is
a separate defect in version resolution and is recorded in the analysis
on #528; it is not addressed here.
- Also out of scope: `.github/workflows/Test-Actions.yml` builds a
Pester configuration with `Run.Parallel` and `Run.Shuffle`, asserts the
options applied, then discards it and creates a fresh
`New-PesterConfiguration` for the actual run. Parallel and shuffle are
validated but never used, which is why the `GITHUB_WORKSPACE` race above
could not surface in CI. The suite now passes both sequentially and
under the intended parallel configuration, so enabling it should be
safe.

| Changed surface | Standards checked | Framework docs checked | Result
|
| --- | --- | --- | --- |
| `.github/actions/Publish-PSModule/src/**` (PowerShell) | Coding
standards, error handling | Publish stage contract | Aligned |
| `.github/actions/Publish-PSModule/tests/**` (Pester) | Pester test
standards | Action test layout | Aligned |
| `.github/actions/Release-PSModule/tests/**` (Pester) | Pester test
standards | Action test layout | Aligned |

</details>

<details>
<summary>Relevant issues (or links)</summary>

- Resolves #528

### Related work

- References #512

</details>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MariusStorhaug <17722253+MariusStorhaug@users.noreply.github.com>
Co-authored-by: Marius Storhaug <Marius.Storhaug@dnb.no>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
PSModule/Process-PSModule#529 merged and shipped in v8.0.4, so the publish
fix is available from the v8 tag. The temporary branch pin is no longer
needed, and the branch it referenced has been deleted.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mariusstorhaug-shelly

Copy link
Copy Markdown

✅ New prerelease: PowerShell Gallery - MariusTestModule 0.4.13-validatepublishfixpr529002

@mariusstorhaug-shelly

Copy link
Copy Markdown

✅ New prerelease: GitHub - MariusTestModule v0.4.13-validatepublishfixpr529002

@MariusStorhaug
MariusStorhaug marked this pull request as ready for review September 2, 2026 08:35
@MariusStorhaug
MariusStorhaug merged commit c3cdb86 into main Sep 2, 2026
29 checks passed
@MariusStorhaug
MariusStorhaug deleted the validate-publish-fix-pr529 branch September 2, 2026 08:35
@mariusstorhaug-shelly

Copy link
Copy Markdown

✅ New release: PowerShell Gallery - MariusTestModule 0.4.13

@mariusstorhaug-shelly

Copy link
Copy Markdown

✅ New release: GitHub - MariusTestModule v0.4.13

@arnaudcharles

Copy link
Copy Markdown

Changed my PSWEE workflow to used the commit with the fix and I can confirm it's working ! Thanks @MariusStorhaug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants