AddonPack/.gitea/workflows/release.yml
Florian Berthold 9154d56750 fix(pack): valid manifest YAML, stable-release picker, tolerant asset re-upload
- manifest: single-quote the coa-template note - nested double quotes
  made the scalar invalid YAML (awk include-parser unaffected; it only
  reads repo:/include: lines)
- build_pack: releases?limit=1 could hand back a prerelease/draft;
  fetch limit=10 and jq-select the first stable release
- release.yml: re-running for an existing tag 409'd on duplicate asset
  names and set -euo pipefail killed the job; skip already-attached
  assets / warn on failed uploads and only fail when the release ends
  up with zero assets
2026-06-10 02:17:21 +02:00

71 lines
3 KiB
YAML

name: release-pack
on:
push:
tags:
- '20*' # date-based: 2026.05.25 etc.
jobs:
pack:
runs-on: linux-amd64
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build pack
run: bash tools/build_pack.sh --tag "${{ github.ref_name }}"
- name: Publish release (Gitea API direct; no action dependency)
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
TAG: ${{ github.ref_name }}
API: ${{ github.server_url }}/api/v1
run: |
set -euo pipefail
# Create the release (or reuse if it already exists for this tag).
RID=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
"$API/repos/$REPO/releases/tags/$TAG" 2>/dev/null \
| jq -r '.id // empty')
if [ -z "$RID" ]; then
RID=$(curl -sf -X POST -H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
"$API/repos/$REPO/releases" \
-d "$(jq -nc --arg t "$TAG" '{tag_name:$t,name:$t,draft:false,prerelease:false,hide_archive_links:true}')" \
| jq -r '.id')
fi
echo "release id: $RID"
# Gitea honors hide_archive_links only on edit, not create — PATCH it
# so the auto-generated Source Code (zip/tar.gz) links stay hidden.
curl -sf -X PATCH -H "Authorization: token $GITEA_TOKEN" -H "Content-Type: application/json" \
"$API/repos/$REPO/releases/$RID" -d '{"hide_archive_links":true}' >/dev/null || true
# Upload every dist/*.zip. Re-running for an existing tag 409s on
# duplicate asset names - warn and keep going instead of letting
# set -e kill the job; only fail if the release ends up with zero
# assets.
existing=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
"$API/repos/$REPO/releases/$RID/assets" | jq -r '.[].name' || true)
uploaded=0
present=0
for f in dist/*.zip; do
name=$(basename "$f")
if printf '%s\n' "$existing" | grep -qxF "$name"; then
echo "::warning::$name already attached (re-run for existing tag) - skipping"
present=$((present+1))
continue
fi
echo "uploading $name"
if curl -sf -X POST -H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@$f" \
"$API/repos/$REPO/releases/$RID/assets?name=$name" \
| jq -r '" -> " + .browser_download_url'; then
uploaded=$((uploaded+1))
else
echo "::warning::upload failed for $name (duplicate asset on re-run?)"
fi
done
echo "release published: $uploaded uploaded, $present already present"
# Only fail the job if NO assets ended up on the release.
[ "$((uploaded + present))" -gt 0 ]