From 7f91c189dbcdc711430f964125ad57224cc2f416 Mon Sep 17 00:00:00 2001 From: alvinlollo Date: Wed, 16 Sep 2026 22:44:05 +1000 Subject: [PATCH] Mirror releases and seed README in AlvinArch-releases for discovery Create a matching git tag + release in alvinlollo/AlvinArch-releases next to the main repo release, seed a short README there pointing back to AlvinArch (workflow status badges on top), and extend release pruning to the releases repo so both stay capped at 3. --- .gitea/workflows/build-iso.yaml | 65 +++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/.gitea/workflows/build-iso.yaml b/.gitea/workflows/build-iso.yaml index f5b4496..474c182 100644 --- a/.gitea/workflows/build-iso.yaml +++ b/.gitea/workflows/build-iso.yaml @@ -162,9 +162,23 @@ jobs: for zst in "${zst_files[@]}"; do cp "$zst" "$REPO_DIR/releases/$TAG_NAME/" done + + # Seed a short README redirecting to the main repo (status badges on top) + cat > "$REPO_DIR/README.md" <<'MDEOF' + [![Scheduled ArchISO Build](https://git.vilaythong.us/alvinlollo/AlvinArch/actions/workflows/build-iso.yaml/badge.svg?branch=main)](https://git.vilaythong.us/alvinlollo/AlvinArch/actions?workflow=build-iso.yaml) + [![Tests](https://git.vilaythong.us/alvinlollo/AlvinArch/actions/workflows/tests.yaml/badge.svg?branch=main)](https://git.vilaythong.us/alvinlollo/AlvinArch/actions?workflow=tests.yaml) + + # AlvinArch Releases + + Compressed (zstd) Arch Linux live ISOs built automatically by + [alvinlollo/AlvinArch](https://git.vilaythong.us/alvinlollo/AlvinArch). + + **Main repository:** [alvinlollo/AlvinArch](https://git.vilaythong.us/alvinlollo/AlvinArch) + MDEOF + git -C "$REPO_DIR" config user.name "Gitea Actions" git -C "$REPO_DIR" config user.email "actions@gitea.local" - git -C "$REPO_DIR" add .gitattributes "releases/$TAG_NAME" + git -C "$REPO_DIR" add .gitattributes README.md "releases/$TAG_NAME" if git -C "$REPO_DIR" diff --cached --quiet; then echo "⚠️ No changes to commit for $TAG_NAME — releasing as-is." >&2 else @@ -212,31 +226,52 @@ jobs: echo " ✅ Released $TAG_NAME (ID: $RELEASE_ID) with download link + SHA-256 checksums" + # Mirror the release tag on the releases repo for redundancy/discovery + if ! git -C "$REPO_DIR" ls-remote --exit-code origin \ + refs/tags/"$TAG_NAME" >/dev/null 2>&1; then + git -C "$REPO_DIR" tag "$TAG_NAME" + if ! git -C "$REPO_DIR" push --quiet origin "$TAG_NAME" 2>/dev/null; then + echo "❌ Failed to push tag $TAG_NAME to $RELEASES_REPO." >&2 + exit 1 + fi + fi + if ! curl -sf -o /dev/null -H "Authorization: token $GITEA_TOKEN" \ + "$GITEA_API/repos/$RELEASES_REPO/releases/tags/$TAG_NAME"; then + curl -sf -X POST \ + -H "Authorization: token $GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + "$GITEA_API/repos/$RELEASES_REPO/releases" \ + -d "$payload" > /dev/null + echo " ✅ Mirrored $TAG_NAME release on $RELEASES_REPO" + fi + - name: Keep only latest 3 releases if: success() env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_API: http://192.168.1.168:3000/api/v1 REPOSITORY: ${{ github.repository }} + RELEASES_REPO: alvinlollo/AlvinArch-releases run: | set -euo pipefail test -n "$GITEA_TOKEN" - # Fetch all release ids, oldest first - readarray -t ids < <(curl -sf -H "Authorization: token $GITEA_TOKEN" \ - "$GITEA_API/repos/$REPOSITORY/releases" \ - | jq -er 'sort_by(.created_at) | .[].id') + for repo in "$REPOSITORY" "$RELEASES_REPO"; do + echo "Pruning old releases in $repo..." + readarray -t ids < <(curl -sf -H "Authorization: token $GITEA_TOKEN" \ + "$GITEA_API/repos/$repo/releases" \ + | jq -er 'sort_by(.created_at) | .[].id') - # Delete the oldest releases, keeping only the 3 newest - to_delete=$(( ${#ids[@]} - 3 )) - if (( to_delete > 0 )); then - for ((i = 0; i < to_delete; i++)); do - id=${ids[$i]} - echo "Deleting old release ID: $id" - curl -sf -X DELETE -H "Authorization: token $GITEA_TOKEN" \ - "$GITEA_API/repos/$REPOSITORY/releases/$id" - done - fi + to_delete=$(( ${#ids[@]} - 3 )) + if (( to_delete > 0 )); then + for ((i = 0; i < to_delete; i++)); do + id=${ids[$i]} + echo "Deleting old release ID: $id (in $repo)" + curl -sf -X DELETE -H "Authorization: token $GITEA_TOKEN" \ + "$GITEA_API/repos/$repo/releases/$id" + done + fi + done - name: Cleanup mkarchiso mounts and workdirs if: always() # Runs on success, failure, or cancellation