Mirror releases and seed README in AlvinArch-releases for discovery
Tests / tests (push) Successful in 2m22s

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.
This commit is contained in:
alvinlollo
2026-09-16 22:44:05 +10:00
parent 3816877b12
commit 7f91c189db
+50 -15
View File
@@ -162,9 +162,23 @@ jobs:
for zst in "${zst_files[@]}"; do for zst in "${zst_files[@]}"; do
cp "$zst" "$REPO_DIR/releases/$TAG_NAME/" cp "$zst" "$REPO_DIR/releases/$TAG_NAME/"
done 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.name "Gitea Actions"
git -C "$REPO_DIR" config user.email "actions@gitea.local" 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 if git -C "$REPO_DIR" diff --cached --quiet; then
echo "⚠️ No changes to commit for $TAG_NAME — releasing as-is." >&2 echo "⚠️ No changes to commit for $TAG_NAME — releasing as-is." >&2
else else
@@ -212,31 +226,52 @@ jobs:
echo " ✅ Released $TAG_NAME (ID: $RELEASE_ID) with download link + SHA-256 checksums" 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 - name: Keep only latest 3 releases
if: success() if: success()
env: env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
GITEA_API: http://192.168.1.168:3000/api/v1 GITEA_API: http://192.168.1.168:3000/api/v1
REPOSITORY: ${{ github.repository }} REPOSITORY: ${{ github.repository }}
RELEASES_REPO: alvinlollo/AlvinArch-releases
run: | run: |
set -euo pipefail set -euo pipefail
test -n "$GITEA_TOKEN" test -n "$GITEA_TOKEN"
# Fetch all release ids, oldest first for repo in "$REPOSITORY" "$RELEASES_REPO"; do
readarray -t ids < <(curl -sf -H "Authorization: token $GITEA_TOKEN" \ echo "Pruning old releases in $repo..."
"$GITEA_API/repos/$REPOSITORY/releases" \ readarray -t ids < <(curl -sf -H "Authorization: token $GITEA_TOKEN" \
| jq -er 'sort_by(.created_at) | .[].id') "$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 ))
to_delete=$(( ${#ids[@]} - 3 )) if (( to_delete > 0 )); then
if (( to_delete > 0 )); then for ((i = 0; i < to_delete; i++)); do
for ((i = 0; i < to_delete; i++)); do id=${ids[$i]}
id=${ids[$i]} echo "Deleting old release ID: $id (in $repo)"
echo "Deleting old release ID: $id" curl -sf -X DELETE -H "Authorization: token $GITEA_TOKEN" \
curl -sf -X DELETE -H "Authorization: token $GITEA_TOKEN" \ "$GITEA_API/repos/$repo/releases/$id"
"$GITEA_API/repos/$REPOSITORY/releases/$id" done
done fi
fi done
- name: Cleanup mkarchiso mounts and workdirs - name: Cleanup mkarchiso mounts and workdirs
if: always() # Runs on success, failure, or cancellation if: always() # Runs on success, failure, or cancellation