ci: respect GITHUB_REPOSITORY + tolerate per-asset upload failures
release / release (push) Successful in 5s

This commit is contained in:
2026-05-25 12:16:18 +02:00
parent 9dded5343f
commit d41b97ca8b
2 changed files with 40 additions and 7 deletions
+26 -4
View File
@@ -24,6 +24,9 @@ jobs:
REPO: ${{ github.repository }} REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }} TAG: ${{ github.ref_name }}
API: ${{ github.server_url }}/api/v1 API: ${{ github.server_url }}/api/v1
# Gitea attachment ceiling is 200 MiB (see roles/gitea config).
# Skip anything larger so one oversized asset doesn't fail the job.
MAX_BYTES: 209715200
run: | run: |
set -euo pipefail set -euo pipefail
# Create the release (or reuse if it already exists for this tag). # Create the release (or reuse if it already exists for this tag).
@@ -38,12 +41,31 @@ jobs:
| jq -r '.id') | jq -r '.id')
fi fi
echo "release id: $RID" echo "release id: $RID"
# Upload every dist/*.zip # Upload every dist/*.zip. Per-asset failures don't fail the job —
# we want partial releases to still publish rather than block the
# whole pipeline on one big file.
failed=0
uploaded=0
for f in dist/*.zip; do for f in dist/*.zip; do
name=$(basename "$f") name=$(basename "$f")
echo "uploading $name" size=$(stat -c '%s' "$f")
curl -sf -X POST -H "Authorization: token $GITEA_TOKEN" \ if [ "$size" -gt "$MAX_BYTES" ]; then
echo "::warning::skip $name (${size} B > ${MAX_BYTES} B Gitea limit; host on CDN instead)"
failed=$((failed+1))
continue
fi
echo "uploading $name ($(numfmt --to=iec "$size"))"
if curl -sf -X POST -H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@$f" \ -F "attachment=@$f" \
"$API/repos/$REPO/releases/$RID/assets?name=$name" \ "$API/repos/$REPO/releases/$RID/assets?name=$name" \
| jq -r '" -> " + .browser_download_url' | jq -r '" -> " + .browser_download_url'; then
uploaded=$((uploaded+1))
else
echo "::warning::upload failed for $name"
failed=$((failed+1))
fi
done done
echo "release published: $uploaded uploaded, $failed skipped/failed"
# Only fail the job if NO assets uploaded — a release with zero
# attachments isn't useful to anyone.
[ "$uploaded" -gt 0 ]
+12 -1
View File
@@ -6,12 +6,23 @@
# - Always archives HEAD, so the working tree state is irrelevant. # - Always archives HEAD, so the working tree state is irrelevant.
# - If more than one addon folder is present, also emits <repo>-all.zip # - If more than one addon folder is present, also emits <repo>-all.zip
# with every addon folder side-by-side at the zip root. # with every addon folder side-by-side at the zip root.
# - When run inside Gitea Actions the working tree lives under a
# per-job dir like /var/lib/act_runner/work/.../hostexecutor, so the
# repo name comes from $GITHUB_REPOSITORY (set by the runner) and
# only falls back to the toplevel basename for local invocations.
set -euo pipefail set -euo pipefail
root=$(git rev-parse --show-toplevel) root=$(git rev-parse --show-toplevel)
cd "$root" cd "$root"
repo_name=$(basename "$root") # Gitea Actions sets GITHUB_REPOSITORY=owner/repo. The basename of
# `git rev-parse --show-toplevel` inside the runner is the worker dir
# (e.g. `hostexecutor`), which would name the bundle wrong.
if [ -n "${GITHUB_REPOSITORY:-}" ]; then
repo_name="${GITHUB_REPOSITORY##*/}"
else
repo_name=$(basename "$root")
fi
dist="$root/dist" dist="$root/dist"
# Find Foo/Foo.toc pairs at depth 1; ignore libs nested deeper. # Find Foo/Foo.toc pairs at depth 1; ignore libs nested deeper.