Skip to content

🚀 [Feature]: Version output always emitted regardless of publish decision#4

Open
Marius Storhaug (MariusStorhaug) wants to merge 18 commits into
mainfrom
feat/348-always-emit-version
Open

🚀 [Feature]: Version output always emitted regardless of publish decision#4
Marius Storhaug (MariusStorhaug) wants to merge 18 commits into
mainfrom
feat/348-always-emit-version

Conversation

@MariusStorhaug
Copy link
Copy Markdown
Member

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented May 27, 2026

The action now always emits a valid Version and FullVersion output, even when no release will be created. Non-publishable builds receive a development prerelease version so downstream jobs always have a version to stamp into the artifact.

New: Development prerelease version for non-publishable builds

When ShouldPublish is false, the action now emits a development prerelease version (e.g. 1.2.4-mybranch001) instead of empty strings. The CreateRelease output remains false — downstream jobs continue to use this flag to gate publishing.

When ShouldPublish is true, behavior is unchanged.

Technical Details

  • Moved version resolution (GitHub releases + PSGallery query) outside the ShouldPublish conditional so it always executes.
  • When ShouldPublish is false, the existing Get-NextModuleVersion is called with a forced patch bump and the branch-based prerelease tag (reusing existing IncrementalPrerelease / DatePrereleaseFormat logic).
  • Made Write-ActionOutput's NewVersion parameter mandatory (always receives a value now).
  • Added Pester tests covering all non-publish scenarios and existing bump behavior.
  • Implementation plan progress: Core changes and Tests tasks in Resolve-PSModuleVersion: Always emit a version regardless of publish decision Process-PSModule#348 completed; Validation task remains.
Related issues

Refactor main.ps1 to always resolve the latest published version and
compute a next version. When ShouldPublish is false, a development
prerelease version (patch bump + branch name) is produced via the new
Get-DevVersion helper function.

This ensures Version and FullVersion outputs are never empty, enabling
downstream Build-Module to stamp a valid version into the manifest for
every CI run.

Fixes PSModule/Process-PSModule#348
…thesized decision

Non-publishable builds now pass a synthesized prerelease decision
(patch bump + prerelease flag) to the existing Get-NextModuleVersion
function — no separate function needed. The original decision is
preserved for Write-ActionOutput so CreateRelease stays false.
When ShouldPublish is false, Resolve-ReleaseDecision now defaults to
CreatePrerelease + PatchRelease so Get-NextModuleVersion always has a
valid bump. This removes the synthesized decision from main.ps1 and
keeps version strategy logic in one place.
@MariusStorhaug Marius Storhaug (MariusStorhaug) marked this pull request as ready for review May 27, 2026 19:52
Copilot AI review requested due to automatic review settings May 27, 2026 19:52
@MariusStorhaug Marius Storhaug (MariusStorhaug) changed the title feat: Always emit version regardless of publish decision 🚀 [Feature]: Version output always emitted regardless of publish decision May 27, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Resolve-PSModuleVersion GitHub Action so it always resolves and emits Version / FullVersion outputs on successful runs, including when no release will be published (non-publish runs now produce a dev prerelease version).

Changes:

  • Always resolves latest published version (GitHub releases + PSGallery) and always computes NewVersion, regardless of ShouldPublish.
  • Adjusts release-decision/versioning logic to produce a patch-bumped prerelease (with incremental counter) for non-publish runs, and makes Write-ActionOutput -NewVersion mandatory.
  • Replaces bespoke workflow-based action tests with Pester tests + data-driven test cases.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/README.md Removes placeholder test README.
tests/Helpers.Tests.ps1 Adds Pester tests for release decision + version computation behavior.
tests/Helpers.Tests.Data.psd1 Adds data sets driving the new Pester tests.
scripts/main.ps1 Moves version resolution outside ShouldPublish and always computes/emits a version.
scripts/Helpers.psm1 Updates decision/version logic and output emission to ensure outputs are always populated.
action.yml Exposes GH_TOKEN to the action step so gh commands work reliably.
.github/workflows/Action-Test.yml Simplifies CI to run Pester tests via PSModule/Invoke-Pester.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/Helpers.psm1 Outdated
Comment thread scripts/Helpers.psm1
Comment thread tests/Helpers.Tests.ps1 Outdated
Comment thread tests/Helpers.Tests.ps1 Outdated
Comment thread tests/Helpers.Tests.Data.psd1
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

scripts/Helpers.psm1:583

  • Get-NextPrereleaseNumber can throw terminating errors (e.g., PSGallery connectivity issues). Since this branch now executes for all non-publishable builds (-not $Decision.ShouldPublish), a transient PSGallery failure would fail otherwise non-publishing PR builds. Consider wrapping the call in try/catch here (with a safe fallback like '001' or GH-only calculation) so version stamping remains reliable.
            if ($Configuration.IncrementalPrerelease -or -not $Decision.ShouldPublish) {
                $baseVersionString = "$($newVersion.Major).$($newVersion.Minor).$($newVersion.Patch)"
                $params = @{
                    ModuleName     = $ModuleName
                    BaseVersion    = $baseVersionString

Comment thread tests/Helpers.Tests.ps1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resolve-PSModuleVersion: Always emit a version regardless of publish decision

2 participants