Explorar o código

chore: temporary backfill workflow for r20 missing assets (to be removed after use)

James McConnell hai 5 días
pai
achega
b45d942ebf
Modificáronse 1 ficheiros con 73 adicións e 0 borrados
  1. 73 0
      .github/workflows/backfill-release.yml

+ 73 - 0
.github/workflows/backfill-release.yml

@@ -0,0 +1,73 @@
+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"