From d3288e29eb89062db97b2f75eae17ed274edc795 Mon Sep 17 00:00:00 2001 From: Julian Cuni Date: Thu, 3 Sep 2026 10:33:03 +0200 Subject: [PATCH] fix(release): don't let a grep-not-found kill the script under set -e MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every REL_ID lookup piped grep -o '"id":...' straight into head/cut with no guard. Under set -e + pipefail, a Gitea API response with no id (e.g. "tag already exists" on a retry, or an empty existing-assets list on the first desktop-latest publish) makes grep exit 1, which aborts the whole step immediately — before the intended fallback lookup ever runs. Hit on retrying v0.1.0 after the previous filename fix: the release already existed from the earlier failed run, and the script died with no output at all instead of finding it by tag. Guarded every such pipeline with || true. --- .gitea/workflows/release.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index c49bc2f..146b676 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -152,12 +152,12 @@ jobs: -H "Content-Type: application/json" \ -d "{\"tag_name\":\"${TAG}\",\"name\":\"${TAG}\",\"draft\":false,\"prerelease\":false}" \ "${API}/repos/${REPO}/releases" || true) - REL_ID=$(printf '%s' "$REL" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2) + REL_ID=$(printf '%s' "$REL" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true) if [ -z "$REL_ID" ]; then # Release may already exist for this tag — look it up by tag. REL_ID=$(curl -sS -H "Authorization: token ${TOKEN}" \ "${API}/repos/${REPO}/releases/tags/${TAG}" \ - | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2) + | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true) fi echo "release id: ${REL_ID}" for f in dist/*; do @@ -201,11 +201,11 @@ jobs: -H "Content-Type: application/json" \ -d "{\"tag_name\":\"${mirror_tag}\",\"name\":\"Parking System ${TAG}\",\"draft\":false,\"prerelease\":${prerelease}}" \ "${API}/repos/${MIRROR_REPO}/releases" || true) - REL_ID=$(printf '%s' "$REL" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2) + REL_ID=$(printf '%s' "$REL" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true) if [ -z "$REL_ID" ]; then REL_ID=$(curl -sS -H "Authorization: token ${TOKEN}" \ "${API}/repos/${MIRROR_REPO}/releases/tags/${mirror_tag}" \ - | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2) + | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2 || true) fi } upload_assets() { @@ -236,6 +236,6 @@ jobs: printf '%s' "$EXISTING" | grep -o '"id":[0-9]*' | cut -d: -f2 | while read -r asset_id; do curl -sS -X DELETE -H "Authorization: token ${TOKEN}" \ "${API}/repos/${MIRROR_REPO}/releases/${LATEST_REL_ID}/assets/${asset_id}" >/dev/null - done + done || true upload_assets "${LATEST_REL_ID}" echo "done"