Skip to content

fix(release): return 'latest' to the newest tag after publishing a draft - #471

Merged
dimetron merged 1 commit into
mainfrom
fix/release-latest-guard
Nov 14, 2026
Merged

dimetron merged 1 commit into
mainfrom
fix/release-latest-guard

Conversation

@dimetron

Copy link
Copy Markdown
Owner

Problem

Publishing a draft release makes GitHub mark it latest. That is wrong whenever a re-run publishes an older tag — which is the normal recovery path the publish job exists for.

Measured on 2026-11-14: publishing the v0.1.8/v0.1.9/v0.2.0 drafts left /releases/latest answering v0.2.0 while v0.4.1 was the newest release. It had to be corrected by hand twice.

Fix

After flipping the draft public, read the highest published (non-draft, non-prerelease) tag and hand latest back to it.

newest="$(gh release list --repo "${GITHUB_REPOSITORY}" --limit 1000 \
  --exclude-drafts --json tagName,isPrerelease \
  --jq '.[] | select(.isPrerelease | not) | .tagName' | sort -V | tail -1)"
if [ -z "${newest}" ]; then
  echo "warning: could not determine the newest published tag; leaving 'latest' as published"
elif [ "${newest}" != "${GITHUB_REF_NAME}" ]; then
  gh release edit "${newest}" --repo "${GITHUB_REPOSITORY}" --latest
fi

A normal run (publishing the newest tag) is a no-op. An older tag cannot rewrite the headline. An empty result leaves the state alone rather than passing an empty argument to gh release edit.

Verification

Logic exercised against the real repository:

[v0.4.1] -> newest, no-op (keeps latest)
[v0.1.8] -> would restore latest to v0.4.1

Gates:

  • make lint — 0 issues
  • go build ./... — OK
  • workflow YAML parses; bash -n on the extracted step — OK
  • commit signed and verified (git verify-commit)

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.59%. Comparing base (95f9f3f) to head (bf55b4a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #471   +/-   ##
=======================================
  Coverage   91.59%   91.59%           
=======================================
  Files         390      390           
  Lines       50146    50146           
=======================================
+ Hits        45929    45930    +1     
+ Misses       4211     4210    -1     
  Partials        6        6           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Publishing a draft makes GitHub mark it `latest`, which is wrong whenever a
re-run publishes an older tag -- the exact recovery path this job exists for.
On 2026-11-14, publishing the v0.1.8/v0.1.9/v0.2.0 drafts left
/releases/latest answering v0.2.0 until it was corrected by hand.

After flipping the draft public, compare the published tag against the highest
published version and hand 'latest' back to it. A v0.4.1-style run is a no-op;
an older tag cannot rewrite the headline.

Signed-off-by: pi <dimetron@me.com>
@dimetron
dimetron force-pushed the fix/release-latest-guard branch from ff3eb9d to bf55b4a Compare November 14, 2026 14:12
@dimetron
dimetron merged commit aa9f94e into main Nov 14, 2026
15 checks passed
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.

1 participant