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

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

When AutoCleanup is enabled (default), this action removes branch prereleases when a pull request closes. It now leaves stable releases and prereleases for other branches unchanged, including branches with empty, short, or differently cased sanitized names.

After GitHub publishes a release with this fix, update the uses reference for PSModule/Release-GHRepository to that release. Keep existing inputs and settings. This fix does not restore releases or tags that earlier runs removed.

Fixed: Cleanup leaves unrelated releases unchanged

Cleanup selects a release only if GitHub marks it as a prerelease and its tag starts with the configured VersionPrefix, a SemVer version, and the exact sanitized branch name as its first prerelease identifier. Matching is case-sensitive. If sanitization produces an empty identifier, cleanup selects no releases and logs a warning.

Plain, incremental, and date-based prereleases for the same branch remain eligible after an unmerged close or merge. This change does not add or remove action inputs or settings.

Migration guide
  1. After GitHub publishes a release that contains this fix, update the uses reference for PSModule/Release-GHRepository to that release.
  2. Keep the existing action inputs and settings; no input migration is required.
Technical details

Publication evidence. GitHub's latest release record is v2.0.3, record 351975133, published 2026-07-10T08:29:31Z. Its lightweight tag currently resolves to commit 750abed0ecab02394554b610dc3aa191e75e3248, but the release record says immutable=false; this current pointer does not prove its original publication target.

The successful Release workflow run has a retained check annotation, Release created: v2.0.3, which links that release name to the run. The run is for PR #106 and reports head 2eff1d0417281f9dd3da2fae69ae3f17c9eb8186; it does not report the release target commit. Its logs are no longer available (HTTP 410), and it has no retained artifacts. The release workflow's stable-release command does not specify --target. Therefore, the original tag-to-commit binding and publication-to-candidate source range are unverified. Do not treat v2.0.3 as a proven publication baseline.

The fixed candidate is PSModule/Release-GHRepository@9f473cb39d3de649546c62abe497f531345583d5. The PR base is 750abed0ecab02394554b610dc3aa191e75e3248. The PR-base-to-candidate comparison contains three commits and only the three files listed below. This verifies the PR's diff scope, not the full publication-to-candidate range. PSModule/Release-GHRepository#109 is open and outside this candidate.

Producer and completion. The candidate's .github/workflows/Release.yml calls the local action on pull request events to main. Its stable-release path creates GitHub releases when a pull request merges. The candidate keeps the existing AutoCleanup, AutoPatching, version-prefix, and label inputs unchanged. No consumer integration template applies; the README has a usage example, not a managed consumer template.

This PR has no linked delivery issue or plan. The focused open-issue search found PSModule/Release-GHRepository#111, which covers the broader resolver and cleanup behavior, and PSModule/Release-GHRepository#112, which tracks release-decision enforcement; both remain open. This PR fixes branch-safe selection only and resolves neither issue. PSModule/Release-GHRepository#109 is open and does not provide the effective producer for this candidate.

Local validation against the fixed candidate: Pester 6.1.0, 22 passed, 0 failed; PSScriptAnalyzer, 0 diagnostics. GitHub and git operations are mocked.

Changed surface Standards checked Framework docs checked Result
src/main.ps1 PowerShell, Security, Testing README and action.yml input contract Fixed in this PR
tests/ReleaseCleanup.Tests.ps1 PowerShell Testing src/main.ps1 action entry point Aligned
README.md Documentation, Markdown, ASD-STE100 README and action.yml input contract Aligned
Release decision route Release Management .github/workflows/Release.yml, action.yml, and main ruleset Exception - PSModule/Release-GHRepository#112
Related links
Release details

Status: Incomplete. The publication-to-candidate source range is unverified. The native producer also does not map release:* labels or provide a required release-decision check.

The active repository ruleset does not require status checks. Branch protection is absent. GitHub did not provide organization-level rulesets because this request requires the admin:org scope. No checks are currently reported for this branch. This description does not establish a valid Release Management decision or clear publication.

@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