diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index d101047..60d3c3d 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -41,12 +41,31 @@ jobs: # 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 + # 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" - 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' + 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 ] diff --git a/manifest.yaml b/manifest.yaml index 6643eb2..840e3e1 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -12,7 +12,7 @@ addons: - repo: coa-template # template-only — not an installable addon include: false - note: "Gitea "Use This Template" source repo for new coa-* forks." + note: 'Gitea "Use This Template" source repo for new coa-* forks.' - repo: coa-ai-voiceover include: false diff --git a/tools/build_pack.sh b/tools/build_pack.sh index f4477ac..026ef18 100755 --- a/tools/build_pack.sh +++ b/tools/build_pack.sh @@ -78,13 +78,14 @@ manifest_includes() { ' "$MANIFEST" } -# Latest release JSON for a repo, or empty string if none. +# Latest stable release JSON for a repo, or empty string if none. latest_release_json() { local repo="$1" json - json="$(curl -fsS "$API/repos/$ORG/$repo/releases?limit=1" 2>/dev/null || echo '[]')" - # `releases?limit=1` returns an array. Strip the wrapper. + json="$(curl -fsS "$API/repos/$ORG/$repo/releases?limit=10" 2>/dev/null || echo '[]')" + # `releases?limit=N` returns a newest-first array that can contain + # prereleases/drafts - pick the first stable release. if [ "$(printf '%s' "$json" | jq -r 'type')" = "array" ]; then - printf '%s' "$json" | jq -c '.[0] // empty' + printf '%s' "$json" | jq -c '[.[] | select(.prerelease == false and .draft == false)][0] // empty' else printf '' fi