Skip to content

Release cleanup preserves stable and unrelated releases - #113

Open
Marius Storhaug (MariusStorhaug) wants to merge 3 commits into
mainfrom
release-cleanup-safety
Open

Marius Storhaug (MariusStorhaug) wants to merge 3 commits into
mainfrom
release-cleanup-safety

Conversation

@MariusStorhaug

Copy link
Copy Markdown
Member

Release cleanup now fails closed for empty sanitized branch names and only selects prereleases belonging to the intended branch. Stable releases and unrelated releases are no longer selected when a pull request closes, including branches such as _, -, v1, 1, or 0.

Fixed: Cleanup only removes matching branch prereleases

Cleanup requires isPrerelease to be true and an anchored version tag matching the configured VersionPrefix and the exact sanitized branch name as its first prerelease identifier. When sanitization leaves an empty identifier, cleanup selects nothing and reports a warning.

Plain, incremental, and date-based branch prereleases still clean up after an unmerged close or a merge. AutoCleanup, WhatIf previews, custom prefixes, and prefix-free tags retain their supported behavior. No input or configuration changes are required to use this fix. This change does not recover releases or tags deleted by earlier runs.

Technical details
  • Changed src/main.ps1, added tests/ReleaseCleanup.Tests.ps1, and documented cleanup behavior and the local test command in README.md.
  • Regression tests reproduced the original unsafe selection before the fix: empty sanitized identifiers selected all 10 initial release fixtures, including stable releases; short names selected unrelated releases.
  • Pester 6.1.0: 20 passed, 0 failed. Tests cover empty and punctuation-only branches, short/common names, stable releases, unrelated branches, missing prerelease flags, normal cleanup after close and merge, configuration controls, and safe WhatIf previews.
  • PSScriptAnalyzer with repository settings: 0 diagnostics for both changed PowerShell files. git diff --check passed.
  • GitHub and git boundaries are mocked. No real releases or tags were created or deleted; these local tests do not claim live-API validation.
  • Candidate source: ea0c3b1523f4483234db760cc30f72781b04cc08. This draft describes the scoped implementation against main, not a bundled publication-to-candidate release inventory.
Changed surface Standards checked Framework docs checked Result
src/main.ps1 PowerShell, naming, error handling, security README and action input contract Fixed in this PR
tests/ReleaseCleanup.Tests.ps1 PowerShell testing and test-first behavior Action script entry point Aligned
README.md Documentation, Markdown, American English Action input contract Aligned

@MariusStorhaug
Marius Storhaug (MariusStorhaug) marked this pull request as ready for review November 2, 2026 23:29
Copilot AI balanced review requested due to automatic review settings November 2, 2026 23:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The case-insensitive release matcher can delete a release and tag belonging to a distinct, differently cased branch, requiring case-sensitive matching and a regression fixture.

1 open issue
What changed in this PR

This PR narrows branch prerelease cleanup to protect stable releases and unrelated releases when pull requests close.

Changes:

  • Skip cleanup with a warning when the sanitized branch name is empty.
  • Require prerelease status and an anchored tag pattern using the configured prefix and sanitized branch identifier.
  • Add mocked regression tests and document cleanup behavior and the local test command.
File Description
tests/​ReleaseCleanup.Tests.ps1 Adds regression coverage for branch matching, cleanup controls, prefixes, and WhatIf previews.
src/​main.ps1 Replaces substring selection with guarded prerelease filtering.
README.md Documents cleanup safeguards and how to run local tests.

Review effort: Balanced

Comment thread src/main.ps1 Resolved
Copilot AI balanced review requested due to automatic review settings November 3, 2026 08:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approved

No active review issues block the branch-specific prerelease cleanup change.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

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