CI: Prevent hotfixes from overwriting Flathub beta

When 31.0.4 was published, it published to the Flathub beta channel,
which overwrote the running 31.1.0 beta/rc. This was due to an
assumption that we would not publish an out-of-band hotfix release once
we had moved to a new beta release cycle. To prevent this in the future,
we can check the last two releases to see if they are different tag
series and if one is a prerelease.
This commit is contained in:
Ryan Foster
2025-07-02 16:26:17 -04:00
parent dc49a03697
commit c88a364d90
+18 -1
View File
@@ -31,8 +31,25 @@ jobs:
case "${GITHUB_REF_NAME}" in
+([0-9]).+([0-9]).+([0-9]) )
lastPreRelease="$(gh release list --exclude-drafts --limit 10 --json "publishedAt,tagName,isPrerelease" \
--jq '[.[] | select(.isPrerelease == true)] | first | .tagName')"
currentRelease="${GITHUB_REF_NAME}"
isPreReleaseAhead=false
printf '%s\n%s\n' "${currentRelease}" "${lastPreRelease}" | sort --version-sort --reverse --check=quiet &&
isPreReleaseAhead=false || isPreReleaseAhead=true
# Edge case: Sort considers the non-suffixed version older than a suffixed one
if ${isPreReleaseAhead} && [[ "${currentRelease}" == "${lastPreRelease//-*}" ]]; then
isPreReleaseAhead=false
fi
echo 'validTag=true' >> $GITHUB_OUTPUT
echo 'flatpakMatrix=["beta", "stable"]' >> $GITHUB_OUTPUT
if ! ${isPreReleaseAhead}; then
echo 'flatpakMatrix=["beta", "stable"]' >> $GITHUB_OUTPUT
else
echo 'flatpakMatrix=["stable"]' >> $GITHUB_OUTPUT
fi
echo 'updateChannel=stable' >> $GITHUB_OUTPUT
;;
+([0-9]).+([0-9]).+([0-9])-@(beta|rc)*([0-9]) )