diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index b7d8483a3..9aeb85fe4 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -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]) )