fix(ci): match release assets by name, and close the guard block
CI / Build & test (Node 20) (push) Waiting to run
CI / Build & test (Node 24) (push) Waiting to run
CI / Build & test (push) Blocked by required conditions
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
OpenSSF Scorecard / Scorecard analysis (push) Waiting to run
Security / Secret scan (gitleaks) (push) Waiting to run
Security / Dependency scan (OSV-Scanner) (push) Waiting to run
Security / IaC/config scan (Trivy) (push) Waiting to run
Security / License compliance scan (Trivy) (push) Waiting to run
CI / Build & test (Node 20) (push) Waiting to run
CI / Build & test (Node 24) (push) Waiting to run
CI / Build & test (push) Blocked by required conditions
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
OpenSSF Scorecard / Scorecard analysis (push) Waiting to run
Security / Secret scan (gitleaks) (push) Waiting to run
Security / Dependency scan (OSV-Scanner) (push) Waiting to run
Security / IaC/config scan (Trivy) (push) Waiting to run
Security / License compliance scan (Trivy) (push) Waiting to run
Two defects, both mine, and the second hid the first. The cleanup built a regex and matched it against the jq line '<id> <name>', 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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 "<id> <nome>", 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
|
||||
|
||||
Reference in New Issue
Block a user