Skip to content

Commit 89a6487

Browse files
committed
fix(ci): harden desktop prerelease tag computation
An empty stable release list makes `gh ... --jq '.[0].tagName'` print the literal string "null", which `${LATEST:-v0.0.0}` does not treat as empty, producing a malformed tag like `vnull..1-beta.N`. The `|| true` also swallowed a failed release query, silently falling back to v0.0.0 and publishing a channel build that sorts below the shipped stable — installed shells would never see it as an update.
1 parent 5b7cf99 commit 89a6487

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,19 @@ jobs:
710710
# and are always superseded by the next stable. The run-attempt
711711
# suffix keeps re-runs of the same workflow from colliding on the
712712
# tag while preserving semver ordering.
713-
LATEST="$(gh release list --exclude-pre-releases --limit 1 --json tagName --jq '.[0].tagName' || true)"
714-
LATEST="${LATEST:-v0.0.0}"
713+
# Fail loudly if the query itself fails: silently falling back to
714+
# v0.0.0 would publish a channel build that sorts below the shipped
715+
# stable, and installed shells would never see it as an update.
716+
if ! LATEST="$(gh release list --exclude-pre-releases --limit 1 --json tagName --jq '.[0].tagName')"; then
717+
echo "::error::Could not query the latest stable release."
718+
exit 1
719+
fi
720+
# An empty release list makes jq print "null", which ${VAR:-default}
721+
# does not treat as empty. Anything that is not a bare vX.Y.Z means
722+
# "no stable release to build on top of" — start the channel at 0.0.1.
723+
if [[ ! "$LATEST" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
724+
LATEST="v0.0.0"
725+
fi
715726
IFS='.' read -r MAJOR MINOR PATCH <<< "${LATEST#v}"
716727
TAG="v${MAJOR}.${MINOR}.$((PATCH + 1))-${CHANNEL}.${GITHUB_RUN_NUMBER}.${GITHUB_RUN_ATTEMPT}"
717728
NOTES="Automated ${CHANNEL}-channel desktop build from ${GITHUB_REF_NAME} @ ${GITHUB_SHA::7}."

0 commit comments

Comments
 (0)