name: Fetch Root Manager APKs description: >- Download the manager APK artifacts for one root implementation from its upstream CI/build, extract the .apk files, and re-zip each APK into a clean per-manager folder. The caller uploads that folder as a single artifact. inputs: owner: description: Owner of the upstream repo (e.g. KernelSU-Next, tiann, ReSukiSU) required: true repo: description: Upstream repo name required: true source: description: Manager APK source ('run' = CI artifacts, 'release' = latest GitHub release) required: true default: run run_id: description: Upstream Actions run ID (source='run') required: false default: '' want: description: Comma-separated artifact names to download (blank = all). Filters out LKM/ksud noise. required: false default: '' token: description: PAT with read access to the upstream repo (for private/artifact downloads) required: true output_dir: description: Absolute path of the folder to write each extracted .apk file into required: true runs: using: composite steps: - name: Download and zip manager APKs shell: bash run: | set -euo pipefail OWNER="${{ inputs.owner }}" REPO="${{ inputs.repo }}" SRC="${{ inputs.source }}" RUN_ID="${{ inputs.run_id }}" WANT="${{ inputs.want }}" OUT_ABS="${{ inputs.output_dir }}" GH_TOKEN="${{ inputs.token }}" mkdir -p "$OUT_ABS" manager-dl ( cd manager-dl if [ "$SRC" = "release" ]; then echo "Downloading all $REPO manager APKs from latest release" curl -fsSL --retry 5 --retry-delay 5 --retry-all-errors \ -H "Authorization: Bearer ***" \ "https://api.github.com/repos/${OWNER}/${REPO}/releases/latest" > rel.json for URL in $(jq -r '.assets[] | select(.name | endswith(".apk")) | .browser_download_url' rel.json); do NAME="${URL##*/}" curl -fsSL --retry 5 --retry-delay 5 --retry-all-errors -o "/tmp/$NAME" "$URL" cp -f "/tmp/$NAME" "$OUT_ABS/$NAME" done else echo "Downloading $REPO manager from run $RUN_ID" ARTIFACTS_JSON=$(curl -fsSL --retry 5 --retry-delay 5 --retry-all-errors \ -H "Authorization: Bearer $GH_TOKEN" \ "https://api.github.com/repos/${OWNER}/${REPO}/actions/runs/${RUN_ID}/artifacts") if [ -z "$WANT" ]; then ARTIFACT_IDS=$(echo "$ARTIFACTS_JSON" | jq -r '.artifacts[].id') else ARTIFACT_IDS=$(echo "$ARTIFACTS_JSON" | jq -r --arg want "$WANT" ' ($want | split(",")) as $wl | .artifacts[] | select(.name as $n | any($wl[]; $n == .)) | .id') fi echo "$ARTIFACT_IDS" | while read -r AID; do [ -n "$AID" ] || continue curl -fsSL --retry 5 --retry-delay 5 --retry-all-errors \ -H "Authorization: Bearer $GH_TOKEN" \ -o "_${AID}.zip" \ "https://api.github.com/repos/${OWNER}/${REPO}/actions/artifacts/${AID}/zip" mkdir -p "_${AID}" unzip -o -q "_${AID}.zip" -d "_${AID}" || true rm -f "_${AID}.zip" for apk in _${AID}/*.apk; do [ -f "$apk" ] || continue cp -f "$apk" "$OUT_ABS/$(basename "$apk")" done rm -rf "_${AID}" done fi ) rm -rf manager-dl - name: Print produced manager zips shell: bash run: | echo "Manager APK zips in ${{ inputs.output_dir }}:" find "${{ inputs.output_dir }}" -maxdepth 1 -type f -iname '*.zip' -printf '%f\n' | sort