From 293378293d20e430451d61ac199fddda3ac9e4db Mon Sep 17 00:00:00 2001 From: devsyncwrld Date: Tue, 1 Sep 2026 19:14:59 -0300 Subject: [PATCH] fix(ci): match release assets by name, and close the guard block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two defects, both mine, and the second hid the first. The cleanup built a regex and matched it against the jq line ' ', so the anchor in latest.yml could never match — it sits after the id. Only the .exe was removed, and each publish left another latest.yml behind. Gitea then served the older one, so the updater kept reporting the previous version as current: an update that exists and is never offered, with nothing logged anywhere. Filtering now happens inside jq, comparing the name directly. The guard meant to catch exactly that was missing its closing fi, so the step died on a syntax error before reaching it. Verified with bash -n this time, which is what should have happened before it ever ran on a runner. Co-Authored-By: Claude Opus 5 --- .github/workflows/publish-gitea.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-gitea.yml b/.github/workflows/publish-gitea.yml index bbb280f7..d04daca3 100644 --- a/.github/workflows/publish-gitea.yml +++ b/.github/workflows/publish-gitea.yml @@ -158,19 +158,26 @@ jobs: # expressão do Actions dentro de um `case`, e quando ela não casou o # laço passou em silêncio — a release ficou com dois latest.yml e o # updater serviu o antigo, dizendo que a versão nova não existia. - if [ "${RUNNER_OS:-}" = "Windows" ]; then - MINE='\.exe$|^latest\.yml$' - else - MINE='\.AppImage$|\.deb$|^latest-linux\.yml$' - fi - R=$(api GET "/releases/$ID/assets") if [ "$(code "$R")" != "200" ]; then echo "::error::não foi possível listar os anexos — HTTP $(code "$R"): $(body "$R")" exit 1 fi - OLD=$(body "$R" | jq -r '.[] | "\(.id) \(.name)"' | grep -E " .*($MINE)" || true) + # Filtro dentro do jq, comparando o nome direto. A versão anterior + # montava um regex e o casava contra " ", onde o `^` de + # `^latest\.yml$` ancorava no início da linha — depois do id — e nunca + # podia casar. O laço então só removia os .exe e deixava um latest.yml + # duplicado, que é o arquivo que decide se há atualização. + OLD=$(body "$R" | jq -r --arg os "${RUNNER_OS:-}" ' + .[] + | select( + if $os == "Windows" + then (.name | endswith(".exe")) or .name == "latest.yml" + else (.name | endswith(".AppImage")) or (.name | endswith(".deb")) or .name == "latest-linux.yml" + end + ) + | "\(.id) \(.name)"') echo "anexos desta plataforma já na release: $(printf '%s' "$OLD" | grep -c . || true)" if [ -n "$OLD" ]; then printf '%s\n' "$OLD" | while read -r aid aname; do @@ -211,3 +218,4 @@ jobs: exit 1 fi echo "latest.yml: 1 cópia, como esperado" + fi