feat: keep highest stable semver as GitHub Latest on release (closes #389)#391
Conversation
WalkthroughThis PR adds a new ChangesEnforce Latest Release Marking
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Pull requests to main can only come from:
Your source branch: Please change the base branch or create a PR from an allowed branch. |
🔍 PR Validation Summary✅ PR Mergeable — no blocking failures
|
🔍 Lint Analysis
|
🛡️ CodeQL Analysis ResultsLanguages analyzed: ✅ No security issues found. 🔍 View full scan logs | 🛡️ Security tab |
There was a problem hiding this comment.
Warning
CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.
Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/release.yml:
- Around line 359-360: Add a one-line explanatory comment immediately above the
permissions: contents: write override that states why this job needs write
access (e.g., it escalates from the top-level contents: read to allow the
release-editing job to create/update releases and push changelog/release
commits) so reviewers and tooling understand the intentional, least-privilege
exception; reference the permissions: contents: write line in your comment.
- Around line 366-367: The current highest= assignment uses `gh release list`
without an explicit --limit so it can miss the true newest stable tag; update
the `gh release list` invocation (used in the `highest` variable) to include a
sufficiently large `--limit` (e.g. --limit 1000 or another number appropriate
for this repo) while keeping the existing `--exclude-pre-releases` and
`--exclude-drafts` filters so the highest stable vX.Y.Z is computed from the
full fetched set.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 8c1cae6c-1050-4685-b2ad-8847827a88e8
📒 Files selected for processing (1)
.github/workflows/release.yml
GitHub Actions Shared Workflows
Description
release.yml'sSemantic Releasestep uses@semantic-release/github, which creates the GitHub release without specifyingmake_latest. The REST API defaultsmake_latesttotrue, so every freshly created release becomes "Latest" regardless of semver ordering. A maintenance-line patch (e.g.v1.6.1frommaintenance/1.6.x) published after a higher main-line release (v1.7.0) therefore steals the "Latest" badge and has to be reverted by hand.This PR adds a post-release job,
enforce_latest, that re-asserts "Latest" to the highest stable semver release in the repo. It is the option-(a) approach from #389: idempotent, correct for any single-app repo, and requires no new input and no change in any consumer.needs.publish_release_status.outputs.release_published == 'true'— so it never runs (and never fails the workflow) when no release was cut.|| trueguards the pipeline so an empty match (no stablevX.Y.Zrelease — e.g. a monorepo using app-prefixed tags, or a pre-1.0 repo) is a clean no-op instead of apipefail/set -eabort.gh release edit --latestis a no-op.notifyjob'sneedsandfailed_jobsso a failure surfaces in the Slack summary.Permissions: the job declares
contents: write(top-level workflow stayscontents: read) and usesgithub.token.Type of Change
feat: New workflow or new input/output/step in an existing workflowBreaking Changes
None. No inputs/outputs/secrets added or changed; existing callers are unaffected.
Testing
yaml.safe_load)@this-branchor the beta tagenforce_latestonly edits the "Latest" flag and is gated onrelease_publishedReference logic validated by the caller workaround documented in #389:
Caller repo / workflow run: motivating case — https://github.com/LerianStudio/plugin-br-pix-indirect-btg/actions/runs/26657889439/job/78572886408
Consumers that benefit
Any repo consuming
release.ymlthat maintains a maintenance/patch line (semver-minor branch such asmaintenance/1.6.x): its patch releases will no longer hijack the "Latest" badge from the main line. Repos with a single linear release history are unaffected (no-op). The caller-sideenforce-latestworkaround can be removed once consumers bump to the version carrying this change.Related Issues
Closes #389
Summary by CodeRabbit