ci: publish pre-release tags as pre-releases and mark only the newest release Latest

Merged
JE
2d ago
+21-0

Description

GoRelease publishes every tag as a normal GitHub Release and lets GitHub choose "Latest" (release-action's default
makeLatest: legacy, by creation date). So v1.10.0-alpha.1, published after v1.9.2, became Latest and had to be
fixed by hand, and a patch on an older line (v1.9.3 after v1.10.0) would take Latest the same way.

A step before publish release now decides both and passes them to release-action:

  • pre-release when the tag has a pre-release suffix (v1.10.0-alpha.1);
  • Latest only when the tag is the highest vX.Y.Z in the repository, the same rule build-image.yml uses for the
    image's latest.

With allowUpdates, prerelease is also applied when the release is updated, so re-running a tag's workflow corrects
it.

I have:

  • Signed off the commits (DCO).

How has this been tested

On my fork (images redirected to my GHCR), with this commit on release-1.9 and release-1.10 and the tags v1.9.2,
v1.10.0-alpha.1, v1.10.0 and v1.9.3:

TagPublishedRelease
v1.9.21stnormal, not Latest (v1.10.0 already existed)
v1.10.02ndnormal, Latest
v1.10.0-alpha.13rd, after v1.10.0pre-release
v1.9.3lastnormal, not Latest

Latest stayed on v1.10.0 throughout. The step logs its decision, e.g. Tag v1.9.3, newest release v1.10.0: prerelease=false, Latest=false.

Special notes for your reviewer

I'll cherry-pick this to release-1.10 and release-1.9 (it applies cleanly to both).


Summary by cubic

Fixes GitHub Releases being marked Latest by creation date instead of version. Pre-release tags like v1.10.0-alpha.1 are now published as pre-releases, and only the highest vX.Y.Z tag is marked Latest, matching the rule build-image.yml uses for the image's latest.

  • A tag with a pre-release suffix (any - in the tag) is published as a pre-release; a patch on an older line (v1.9.3 after v1.10.0) stays a normal, non-Latest release.
  • Because allowUpdates is set, the pre-release and Latest flags are also applied when a tag's workflow is re-run, correcting any previously wrong release state.