Skip to content

🪲 [Fix]: Only resolve a prerelease for open pull requests#11

Open
Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
mainfrom
fix/prerelease-only-for-open-prs
Open

🪲 [Fix]: Only resolve a prerelease for open pull requests#11
Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
mainfrom
fix/prerelease-only-for-open-prs

Conversation

@MariusStorhaug

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Jul 12, 2026

Copy link
Copy Markdown
Member

Note

Role: stopgap. This is the small, architecture-independent guard for the reported bug (a prerelease resolved on merge to the default branch). It holds the invariant "a prerelease is only ever resolved for an open PR" regardless of how releases are triggered, so it survives the planned redesign.

The full fix — moving stable releases to a push-to-main trigger and consolidating the framework scripts into the PSMA action library — is tracked in PSModule/Process-PSModule#384 (builds on #84). This PR is safe to merge now and does not block that work.


Summary Resolve a prerelease only while a pull request is open. A change that has landed on the default branch — a merged/closed pull_request event, or a push to the default branch (which the workflow treats the same as a merged PR) — must never resolve to a prerelease. It resolves to a stable release when the merge warrants one, otherwise it keeps the current version. ## Why Resolve-ReleaseDecision previously ended with: powershell # Anything that is not a published full release is surfaced as a prerelease if (-not $shouldPublish) { $createPrerelease = $true } That fired regardless of whether the run was an open PR or a merge. A merged PR that does not produce a full release (ReleaseType='None' — e.g. the changed files do not match ImportantFilePatterns, a merge to a non-default branch, an ignore/NoRelease label, or no bump label with AutoPatching off) therefore resolved to a prerelease on merge. Because the Plan job stamps the built artifact with this version, that prerelease could be built/published from a merge — it should never exist once the merge decision is made. Prereleases are the mechanism that keeps an in-review artifact from ever masquerading as a stable release. That guarantee only makes sense while the PR is open. ## What changed - Get-GitHubPullRequest now surfaces IsOpen (pull_request.state -eq 'open'), defaulting to not-open when state is absent so we never accidentally prerelease. - Resolve-ReleaseDecision branches on IsOpen: - Open PR → always carries a prerelease tag (published prerelease for ReleaseType='Prerelease', otherwise a non-published preview). An ignore label only suppresses publishing; the reviewed artifact stays a prerelease. - Merged/closed PR or push to the default branch → never a prerelease. A full release when the merge warrants one (ReleaseType='Release' with a determinable bump), otherwise the current version is kept unchanged. ### Behavior matrix | Trigger | Before | After | | --- | --- | --- | | Open PR (no prerelease label) | prerelease preview | prerelease preview (unchanged) | | Open PR (prerelease label) | published prerelease | published prerelease (unchanged) | | Merged PR → default, releasable | stable release | stable release (unchanged) | | Merged PR → default, ReleaseType='None' | prerelease | current version (no prerelease) | | Merged PR, ignore/NoRelease label | prerelease | current version (no prerelease) | | Merged PR, no bump + AutoPatching off | prerelease | current version (no prerelease) | | Push to default branch | current version | current version (unchanged) | ## Tests - All 188 Pester tests pass. - Every Resolve-ReleaseDecision and end-to-end case now carries an explicit IsOpen. - Added cases locking the fix: a merged PR with ReleaseType='None' keeps the current version; a merged PR with an ignore label / no bump keeps the current version; an open PR with an ignore label still previews a prerelease. ## Rollout After this releases (patch → v1.1.6), bump the pin in PSModule/Process-PSModule .github/workflows/Plan.yml (Resolve-PSModuleVersion@…), which flows to consumers on their next Process-PSModule bump. Reported from: https://github.com/PSModule/GoogleFonts/actions/runs/29202094727

Copilot AI review requested due to automatic review settings July 12, 2026 18:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts version resolution so prerelease versions are only produced while a pull request is open, preventing “prerelease-on-merge” outcomes when changes land on the default branch.

Changes:

  • Extend Get-GitHubPullRequest to surface an IsOpen flag derived from pull_request.state.
  • Update Resolve-ReleaseDecision to resolve prereleases only for open PRs; merged/closed PRs (and default-branch pushes) never resolve to a prerelease and instead either produce a stable release or keep the current version.
  • Update/expand Pester test data and cases to explicitly pass IsOpen and cover merged-vs-open behavior.

Reviewed changes

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

File Description
tests/Resolve-PSModuleVersion.Helpers.Tests.ps1 Updates PR-object construction to include IsOpen and adds Get-GitHubPullRequest assertions for open vs closed PR events.
tests/Resolve-PSModuleVersion.Helpers.Tests.Data.psd1 Refreshes/extends test matrices to include IsOpen and validates “no prerelease after merge” scenarios.
scripts/Resolve-PSModuleVersion.Helpers.psm1 Implements IsOpen detection and gates prerelease resolution on open PRs within Resolve-ReleaseDecision.

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

($result.Labels -join ',') | Should -Be 'patch,prerelease'
$result.IsOpen | Should -BeTrue
}

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.

2 participants