From 96dc554d4d7beabe981afcacbcf515c7303c4626 Mon Sep 17 00:00:00 2001 From: Jefino9488 Date: Tue, 28 Apr 2026 10:01:29 +0530 Subject: [PATCH] feat(pages): add searchable build index --- .github/workflows/android13.yml | 1 + .github/workflows/android14.yml | 1 + .github/workflows/android15.yml | 1 + .github/workflows/android16.yml | 1 + .github/workflows/release-engine.yml | 6 + .github/workflows/update-build-index.yml | 18 +- scripts/core/manifest.sh | 6 +- scripts/core/module.sh | 3 +- scripts/core/render_pages_index.py | 597 +++++++++++++++++++++++ scripts/patcher_a13.sh | 2 +- scripts/patcher_a14.sh | 2 +- scripts/patcher_a15.sh | 2 +- scripts/patcher_a16.sh | 2 +- 13 files changed, 631 insertions(+), 11 deletions(-) create mode 100644 scripts/core/render_pages_index.py diff --git a/.github/workflows/android13.yml b/.github/workflows/android13.yml index fda4fc6..3bab7b4 100644 --- a/.github/workflows/android13.yml +++ b/.github/workflows/android13.yml @@ -251,6 +251,7 @@ jobs: export WORKFLOW_RUN_ID="${{ github.run_id }}" export WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + export WORKFLOW_RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/build-tmp-${{ github.run_id }}" ./scripts/patcher_a13.sh \ "${{ github.event.inputs.api_level }}" \ diff --git a/.github/workflows/android14.yml b/.github/workflows/android14.yml index 8afbc3b..d011fc8 100644 --- a/.github/workflows/android14.yml +++ b/.github/workflows/android14.yml @@ -251,6 +251,7 @@ jobs: export WORKFLOW_RUN_ID="${{ github.run_id }}" export WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + export WORKFLOW_RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/build-tmp-${{ github.run_id }}" ./scripts/patcher_a14.sh \ "${{ github.event.inputs.api_level }}" \ diff --git a/.github/workflows/android15.yml b/.github/workflows/android15.yml index 58e96c1..ea5a372 100644 --- a/.github/workflows/android15.yml +++ b/.github/workflows/android15.yml @@ -265,6 +265,7 @@ jobs: # Pass CI metadata for build manifest export WORKFLOW_RUN_ID="${{ github.run_id }}" export WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + export WORKFLOW_RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/build-tmp-${{ github.run_id }}" ./scripts/patcher_a15.sh \ ${{ github.event.inputs.api_level }} \ diff --git a/.github/workflows/android16.yml b/.github/workflows/android16.yml index b36abe4..15f4a11 100644 --- a/.github/workflows/android16.yml +++ b/.github/workflows/android16.yml @@ -260,6 +260,7 @@ jobs: export WORKFLOW_RUN_ID="${{ github.run_id }}" export WORKFLOW_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + export WORKFLOW_RELEASE_URL="https://github.com/${{ github.repository }}/releases/tag/build-tmp-${{ github.run_id }}" ./scripts/patcher_a16.sh \ "${{ github.event.inputs.api_level }}" \ diff --git a/.github/workflows/release-engine.yml b/.github/workflows/release-engine.yml index dd2ea00..1a63d3d 100644 --- a/.github/workflows/release-engine.yml +++ b/.github/workflows/release-engine.yml @@ -18,6 +18,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Render GitHub Pages index + run: | + python3 scripts/core/render_pages_index.py --output /tmp/index.html + - name: Validate version run: | FILE_VERSION=$(tr -d '[:space:]' < VERSION) @@ -105,7 +109,9 @@ jobs: cd gh-pages git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" + cp /tmp/index.html index.html git add builds/latest.json + git add index.html if git diff --cached --quiet; then echo "No latest.json changes to commit" else diff --git a/.github/workflows/update-build-index.yml b/.github/workflows/update-build-index.yml index fd9350a..6acf1a4 100644 --- a/.github/workflows/update-build-index.yml +++ b/.github/workflows/update-build-index.yml @@ -26,6 +26,10 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 + - name: Render GitHub Pages index + run: | + python3 scripts/core/render_pages_index.py --output /tmp/index.html + - name: Setup gh-pages branch run: | git config user.name "github-actions[bot]" @@ -87,11 +91,13 @@ jobs: base_rom = os.environ.get("BASE_ROM", "unknown") device_file = os.environ.get("DEVICE_FILE", f"builds/{device}.json") run_id = "${{ github.event.workflow_run.id }}" - repo = "${{ github.repository }}" with open(manifest_path) as f: manifest = json.load(f) + manifest_release_url = manifest.get("release_url") or manifest.get("workflow_url") + manifest_workflow_url = manifest.get("workflow_url", "") + # Load or create device index if os.path.exists(device_file): with open(device_file) as f: @@ -100,7 +106,6 @@ jobs: device_data = {"device": device, "builds": {}} # Upsert build entry - release_url = f"https://github.com/{repo}/actions/runs/{run_id}" device_data["builds"][base_rom] = { "android_version": manifest.get("android_version", "unknown"), "patch_version": manifest.get("patch_engine_version", "unknown"), @@ -109,7 +114,8 @@ jobs: "git_commit": manifest.get("git_commit", ""), "checksums": manifest.get("checksums", {}), "workflow_run_id": run_id, - "release_url": release_url, + "workflow_url": manifest_workflow_url, + "release_url": manifest_release_url, } device_data["last_updated"] = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ") @@ -133,6 +139,9 @@ jobs: "android_version": manifest.get("android_version", "unknown"), "build_time": manifest.get("build_time", ""), "patch_version": manifest.get("patch_engine_version", "unknown"), + "release_url": manifest_release_url, + "workflow_url": manifest_workflow_url, + "features": manifest.get("features", []), } with open(index_path, "w") as f: @@ -162,7 +171,8 @@ jobs: run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git add builds/ + cp /tmp/index.html index.html + git add index.html builds/ if git diff --cached --quiet; then echo "No changes to commit" else diff --git a/scripts/core/manifest.sh b/scripts/core/manifest.sh index 542c52e..a9fce8f 100644 --- a/scripts/core/manifest.sh +++ b/scripts/core/manifest.sh @@ -3,7 +3,7 @@ # Build manifest generation for traceability and reproducibility. # Requires: PATCH_ENGINE_VERSION (from version.sh) -# Usage: generate_manifest [workflow_run_id] [workflow_url] +# Usage: generate_manifest [workflow_run_id] [workflow_url] [release_url] # Output: writes build-manifest.json to $WORK_DIR (or cwd) generate_manifest() { @@ -14,6 +14,7 @@ generate_manifest() { local features_csv="$5" local workflow_run_id="${6:-local}" local workflow_url="${7:-}" + local release_url="${8:-}" local manifest_file="${WORK_DIR:-.}/build-manifest.json" local git_commit git_branch build_time @@ -74,7 +75,8 @@ except: "apktool": "${apktool_version}" }, "workflow_run_id": "${workflow_run_id}", - "workflow_url": "${workflow_url}" + "workflow_url": "${workflow_url}", + "release_url": "${release_url}" } MANIFEST_EOF diff --git a/scripts/core/module.sh b/scripts/core/module.sh index 3e1d4a1..05cc658 100755 --- a/scripts/core/module.sh +++ b/scripts/core/module.sh @@ -21,6 +21,7 @@ create_module() { local features_csv="${6:-}" local workflow_run_id="${7:-local}" local workflow_url="${8:-}" + local release_url="${9:-}" log "Creating module using FrameworkPatcherModule for $device_name (v$version_name)" @@ -146,7 +147,7 @@ create_module() { fi # Generate build manifest - generate_manifest "$device_name" "$version_name" "${android_version:-unknown}" "${api_level:-unknown}" "$features_csv" "$workflow_run_id" "$workflow_url" + generate_manifest "$device_name" "$version_name" "${android_version:-unknown}" "${api_level:-unknown}" "$features_csv" "$workflow_run_id" "$workflow_url" "$release_url" # Embed manifest in module ZIP local manifest_src="${WORK_DIR:-.}/build-manifest.json" diff --git a/scripts/core/render_pages_index.py b/scripts/core/render_pages_index.py new file mode 100644 index 0000000..ffeb44a --- /dev/null +++ b/scripts/core/render_pages_index.py @@ -0,0 +1,597 @@ +#!/usr/bin/env python3 +"""Render the GitHub Pages build index page. + +The generated page is static and reads the JSON index files at runtime, so the +workflows only need to copy the resulting HTML into the gh-pages branch. +""" + +from __future__ import annotations + +import argparse +from datetime import datetime, timezone +from pathlib import Path +HTML_TEMPLATE = """ + + + + + + __TITLE__ + + + +
+
+ GitHub Pages build index +

FrameworkPatcher builds

+

+ Search the published builds below. Each entry includes the device, ROM target, build metadata, + and a direct release link when one exists. +

+
+
+
Published builds
+
0
+
+
+
Devices tracked
+
0
+
+
+
Last updated
+
Loading
+
+
+
+ +
+
+

Builds

+ +
+ + + +

Loading build index...

+
+ + +
+
+ + + + +""" + + +def main() -> int: + parser = argparse.ArgumentParser(description="Render the FrameworkPatcher GitHub Pages index.") + parser.add_argument("--output", default="-", help="Write the HTML to this path, or '-' for stdout.") + parser.add_argument("--title", default="FrameworkPatcher Builds", help="Page title.") + args = parser.parse_args() + + page = HTML_TEMPLATE.replace("__TITLE__", args.title).replace("$YEAR", str(datetime.now(timezone.utc).year)) + + if args.output == "-": + print(page) + return 0 + + output_path = Path(args.output) + output_path.parent.mkdir(parents=True, exist_ok=True) + output_path.write_text(page, encoding="utf-8") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) \ No newline at end of file diff --git a/scripts/patcher_a13.sh b/scripts/patcher_a13.sh index cfe09d3..668feb7 100755 --- a/scripts/patcher_a13.sh +++ b/scripts/patcher_a13.sh @@ -664,7 +664,7 @@ EOF # Create module with manifest metadata create_module "$API_LEVEL" "$DEVICE_NAME" "$VERSION_NAME" "$FEATURE_KAORIOS_TOOLBOX" \ - "13" "$FEATURES_CSV" "${WORKFLOW_RUN_ID:-local}" "${WORKFLOW_URL:-}" + "13" "$FEATURES_CSV" "${WORKFLOW_RUN_ID:-local}" "${WORKFLOW_URL:-}" "${WORKFLOW_RELEASE_URL:-}" echo "All patching completed successfully!" } diff --git a/scripts/patcher_a14.sh b/scripts/patcher_a14.sh index 512f4ad..1b507f5 100644 --- a/scripts/patcher_a14.sh +++ b/scripts/patcher_a14.sh @@ -664,7 +664,7 @@ EOF # Create module with manifest metadata create_module "$API_LEVEL" "$DEVICE_NAME" "$VERSION_NAME" "$FEATURE_KAORIOS_TOOLBOX" \ - "14" "$FEATURES_CSV" "${WORKFLOW_RUN_ID:-local}" "${WORKFLOW_URL:-}" + "14" "$FEATURES_CSV" "${WORKFLOW_RUN_ID:-local}" "${WORKFLOW_URL:-}" "${WORKFLOW_RELEASE_URL:-}" echo "All patching completed successfully!" } diff --git a/scripts/patcher_a15.sh b/scripts/patcher_a15.sh index 6150be7..429c58f 100644 --- a/scripts/patcher_a15.sh +++ b/scripts/patcher_a15.sh @@ -1420,7 +1420,7 @@ EOF # Create module with manifest metadata create_module "$API_LEVEL" "$DEVICE_NAME" "$VERSION_NAME" "$FEATURE_KAORIOS_TOOLBOX" \ - "15" "$FEATURES_CSV" "${WORKFLOW_RUN_ID:-local}" "${WORKFLOW_URL:-}" + "15" "$FEATURES_CSV" "${WORKFLOW_RUN_ID:-local}" "${WORKFLOW_URL:-}" "${WORKFLOW_RELEASE_URL:-}" echo "All patching completed successfully!" } diff --git a/scripts/patcher_a16.sh b/scripts/patcher_a16.sh index 80ca2ef..fb03260 100755 --- a/scripts/patcher_a16.sh +++ b/scripts/patcher_a16.sh @@ -1449,7 +1449,7 @@ EOF # Create module with manifest metadata log "Creating Magisk/KSU module..." create_module "$api_level" "$device_name" "$version_name" "$FEATURE_KAORIOS_TOOLBOX" \ - "16" "$FEATURES_CSV" "${WORKFLOW_RUN_ID:-local}" "${WORKFLOW_URL:-}" + "16" "$FEATURES_CSV" "${WORKFLOW_RUN_ID:-local}" "${WORKFLOW_URL:-}" "${WORKFLOW_RELEASE_URL:-}" log "✓ All operations completed successfully!" }