| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- name: Backfill Release Assets
- # One-off repair: upload artifacts from an existing run that the release
- # job missed (e.g. r20, where download-artifact truncation dropped 96
- # AnyKernel3 zips). Delete this file once no longer needed.
- on:
- workflow_dispatch:
- inputs:
- run_id:
- description: "Source run ID holding the artifacts"
- required: true
- type: string
- tag:
- description: "Existing release tag to upload into"
- required: true
- type: string
- permissions:
- contents: write
- actions: read
- jobs:
- backfill:
- runs-on: ubuntu-latest
- env:
- GH_TOKEN: ${{ github.token }}
- steps:
- - name: Upload missing AnyKernel3 zips to release
- run: |
- set -euo pipefail
- REPO="${{ github.repository }}"
- RUN_ID="${{ inputs.run_id }}"
- TAG="${{ inputs.tag }}"
- gh api "repos/$REPO/actions/runs/$RUN_ID/artifacts?per_page=100" --paginate --jq '.artifacts[] | select(.name | endswith("-AnyKernel3")) | "\(.id) \(.name)"' > /tmp/all.txt
- echo "AnyKernel3 artifacts in run: $(wc -l < /tmp/all.txt)"
- RID=$(gh api "repos/$REPO/releases/tags/$TAG" --jq '.id')
- gh api "repos/$REPO/releases/$RID/assets?per_page=100" --paginate --jq '.[].name' | sed 's/\.zip$//' | sort -u > /tmp/have.txt
- : > /tmp/missing.txt
- while read -r id name; do
- grep -qx "$name" /tmp/have.txt || echo "$id $name" >> /tmp/missing.txt
- done < /tmp/all.txt
- echo "Missing from $TAG: $(wc -l < /tmp/missing.txt)"
- [ -s /tmp/missing.txt ] || { echo "Nothing to backfill."; exit 0; }
- mkdir -p backfill
- failed=0
- while read -r id name; do
- echo "=== $name ==="
- rm -rf "backfill/$name" "backfill/$name.zip"
- ok=false
- for attempt in 1 2 3; do
- if gh api "repos/$REPO/actions/artifacts/$id/zip" > "backfill/dl.zip" && \
- unzip -q -o "backfill/dl.zip" -d "backfill/$name" && \
- ( cd "backfill/$name" && zip -r -q -9 "../$name.zip" . ) && \
- gh release upload "$TAG" "backfill/$name.zip" --clobber --repo "$REPO"; then
- ok=true
- break
- fi
- echo "Attempt $attempt/3 failed for: $name" >&2
- sleep 10
- done
- if [ "$ok" = false ]; then
- echo "ERROR: giving up on $name" >&2
- failed=1
- fi
- rm -rf "backfill/$name" "backfill/$name.zip" backfill/dl.zip
- done < /tmp/missing.txt
- have_kernels=$(gh api "repos/$REPO/releases/$RID/assets?per_page=100" --paginate --jq '.[].name' | grep -c 'AnyKernel3\.zip$')
- echo "AnyKernel3 zips now on $TAG: $have_kernels (run holds $(wc -l < /tmp/all.txt))"
- exit "$failed"
|