浏览代码

refactor: replace use_latest_commits + commits.json with ksu_branch and susfs_commit inputs

- ksu_branch: accepts branch name or commit hash (empty = latest dev tip)
- susfs_commit: accepts commit hash (empty = latest on auto-derived gki-{version} branch)
- Removed all commits.json references from actions, workflows, and render script
- Simplified commit-status.yml to show only latest upstream commits
- Updated render_release_body.py to use env vars instead of commits.json
TheWildJames 2 月之前
父节点
当前提交
2886aa6c8f

+ 15 - 12
.github/actions/kernelsu/action.yml

@@ -1,10 +1,10 @@
 name: Setup Wild KSU
 description: Download and configure Wild KSU with version tracking
 inputs:
-  use_latest_commits:
-    description: 'Use the latest commit on the branch instead of the pinned commit'
+  ksu_branch:
+    description: 'KernelSU branch or commit (empty = latest dev branch tip)'
     required: false
-    default: true
+    default: ""
 
 runs:
   using: composite
@@ -15,19 +15,22 @@ runs:
       run: |
         set -euo pipefail
 
-        KSU_REPO="https://github.com/KernelSU-Next/KernelSU-Next.git"
-        KSU_BRANCH="dev"
+        KSU_INPUT="${{ inputs.ksu_branch }}"
+        if [ -z "$KSU_INPUT" ]; then
+          KSU_INPUT="dev"
+        fi
 
-        if [ "${{ inputs.use_latest_commits }}" = "true" ]; then
-          echo "Using latest KernelSU-Next from branch: $KSU_BRANCH"
+        # Try as branch first, fall back to commit
+        if git ls-remote --heads https://github.com/KernelSU-Next/KernelSU-Next.git "$KSU_INPUT" | grep -q .; then
+          echo "Using KernelSU-Next branch: $KSU_INPUT"
           curl -LSs "https://raw.githubusercontent.com/pershoot/KernelSU-Next/dev-susfs/kernel/setup.sh" | bash -s dev-susfs
+          git -C KernelSU-Next/kernel fetch --depth=50 origin "$KSU_INPUT"
+          git -C KernelSU-Next/kernel checkout "origin/$KSU_INPUT"
         else
-          COMMITS_JSON="${{ github.workspace }}/.github/config/commits.json"
-          KSU_SETUP_COMMIT=$(jq -er '.kernelsu.dev' "$COMMITS_JSON")
-          echo "Using pinned KernelSU commit: $KSU_SETUP_COMMIT"
+          echo "Using KernelSU-Next commit: $KSU_INPUT"
           curl -LSs "https://raw.githubusercontent.com/pershoot/KernelSU-Next/dev-susfs/kernel/setup.sh" | bash -s dev-susfs
-          git -C KernelSU-Next/kernel fetch --depth=50 origin "$KSU_SETUP_COMMIT"
-          git -C KernelSU-Next/kernel checkout "$KSU_SETUP_COMMIT"
+          git -C KernelSU-Next/kernel fetch --depth=50 origin "$KSU_INPUT"
+          git -C KernelSU-Next/kernel checkout "$KSU_INPUT"
         fi
 
         cd KernelSU-Next/kernel

+ 6 - 7
.github/actions/susfs/action.yml

@@ -1,10 +1,10 @@
 name: Setup SUSFS
 description: Clone and apply SUSFS patches with version-specific fixes
 inputs:
-  use_latest_commits:
-    description: 'Use the latest commit on the branch instead of the pinned commit'
+  susfs_commit:
+    description: 'SUSFS commit hash (empty = latest on auto-derived gki-{version} branch)'
     required: false
-    default: true
+    default: ""
   version:
     description: 'Kernel config version (e.g., android15-6.6)'
     required: true
@@ -36,11 +36,10 @@ runs:
         echo "Cloning latest from $SUSFS_BRANCH..."
         git clone "$SUSFS_REPO" -b "$SUSFS_BRANCH" susfs4ksu
 
-        if [ "${{ inputs.use_latest_commits }}" != "true" ]; then
-          COMMITS_JSON="${{ github.workspace }}/.github/config/commits.json"
-          SUSFS_COMMIT=$(jq -er --arg key "$SUSFS_BRANCH" '.susfs[$key]' "$COMMITS_JSON")
+        if [ -n "${{ inputs.susfs_commit }}" ]; then
+          echo "Checking out SUSFS commit: ${{ inputs.susfs_commit }}"
           cd ${{ github.workspace }}/susfs4ksu
-          git checkout "$SUSFS_COMMIT"
+          git checkout "${{ inputs.susfs_commit }}"
         fi
 
     - name: Enable Kernel Configs

+ 8 - 20
.github/scripts/render_release_body.py

@@ -10,27 +10,17 @@ PLACEHOLDERS = {
     "{{KSUN_BRANCH}}": lambda: os.environ.get("KSUN_BRANCH", "dev"),
     "{{KSUN_COMMIT}}": lambda: os.environ.get("KSUN_COMMIT", "unknown"),
     "{{KSU_MANAGER}}": lambda: os.environ.get("KSU_MANAGER", "Placeholder"),
+    "{{SUSFS_BRANCHES}}": lambda: os.environ.get("SUSFS_COMMIT", "latest on auto-derived gki-{version} branch"),
+    "{{SUSFS_BRANCHS}}": lambda: os.environ.get("SUSFS_COMMIT", "latest on auto-derived gki-{version} branch"),
 }
 
 
 def render_markdown(template_path: Path):
     text = template_path.read_text()
 
-    commits_path = template_path.parent / "commits.json"
-    commits = json.loads(commits_path.read_text()) if commits_path.exists() else {}
-
     for placeholder, getter in PLACEHOLDERS.items():
         text = text.replace(placeholder, getter())
 
-    susfs_branches = []
-    for branch, commit in commits.get("susfs", {}).items():
-        susfs_branches.append(f"**{branch}**\n`{commit}`")
-
-    if "{{SUSFS_BRANCHS}}" in text:
-        text = text.replace("{{SUSFS_BRANCHS}}", "\n".join(susfs_branches))
-    if "{{SUSFS_BRANCHES}}" in text:
-        text = text.replace("{{SUSFS_BRANCHES}}", "\n".join(susfs_branches))
-
     print(text, end="")
 
 
@@ -61,9 +51,6 @@ def emit_description(value):
 
 data = json.loads(config_path.read_text())
 
-commits_path = config_path.parent / "commits.json"
-commits = json.loads(commits_path.read_text()) if commits_path.exists() else {}
-
 emit("**IMPORTANT DISCLAIMER**")
 for line in data["release"]["disclaimer"]:
     emit(line)
@@ -99,11 +86,12 @@ for key in data.keys():
     if section.get("branch"):
         emit(f"- Branch: {section['branch']}")
 
-    if key == "susfs" and "susfs" in commits:
-        emit("- Branches:")
-        for branch, commit in commits["susfs"].items():
-            emit(f"**{branch}**")
-            emit(f"`{commit}`")
+    if key == "susfs":
+        susfs_commit = os.environ.get("SUSFS_COMMIT", "")
+        if susfs_commit:
+            emit(f"- Commit: `{susfs_commit}`")
+        else:
+            emit("- Commit: latest on auto-derived gki-{version} branch")
 
     if section.get("items"):
         emit_list(section["items"])

+ 9 - 5
.github/workflows/build.yml

@@ -27,10 +27,14 @@ on:
       feature_set:
         required: true
         type: string
-      use_latest_commits:
+      ksu_branch:
         required: false
-        type: boolean
-        default: true
+        type: string
+        default: ""
+      susfs_commit:
+        required: false
+        type: string
+        default: ""
 
 jobs:
   build-gki:
@@ -130,13 +134,13 @@ jobs:
       if: contains(inputs.feature_set, 'KSUN') || inputs.feature_set == 'FULL'
       uses: ./.github/actions/kernelsu
       with:
-        use_latest_commits: ${{ inputs.use_latest_commits }}
+        ksu_branch: ${{ inputs.ksu_branch }}
 
     - name: SUSFS
       if: contains(inputs.feature_set, 'SUSFS') || inputs.feature_set == 'FULL'
       uses: ./.github/actions/susfs
       with:
-        use_latest_commits: ${{ inputs.use_latest_commits }}
+        susfs_commit: ${{ inputs.susfs_commit }}
         version: ${{ inputs.version }}
         android_version: ${{ inputs.android_version }}
         kernel_version: ${{ inputs.kernel_version }}

+ 19 - 30
.github/workflows/commit-status.yml

@@ -15,8 +15,6 @@ jobs:
 
       - name: Build commit summary
         shell: bash
-        env:
-          COMMITS_JSON: .github/config/commits.json
         run: |
           set -euo pipefail
 
@@ -30,11 +28,6 @@ jobs:
             printf '%s' "$value"
           }
 
-          gitlab_commit_message() {
-            local sha="$1"
-            curl -fsSL "https://gitlab.com/api/v4/projects/simonpunk%2Fsusfs4ksu/repository/commits/${sha}" | jq -r '.message | split("\n")[0]'
-          }
-
           gitlab_latest_commit() {
             local branch="$1"
             curl -fsSL "https://gitlab.com/api/v4/projects/simonpunk%2Fsusfs4ksu/repository/commits?ref_name=${branch}&per_page=1" | jq -r '.[0].id'
@@ -45,11 +38,6 @@ jobs:
             curl -fsSL "https://gitlab.com/api/v4/projects/simonpunk%2Fsusfs4ksu/repository/commits?ref_name=${branch}&per_page=1" | jq -r '.[0].message | split("\n")[0]'
           }
 
-          github_commit_message() {
-            local sha="$1"
-            curl -fsSL "https://api.github.com/repos/KernelSU-Next/KernelSU-Next/commits/${sha}" | jq -r '.commit.message | split("\n")[0]'
-          }
-
           github_latest_commit() {
             curl -fsSL "https://api.github.com/repos/KernelSU-Next/KernelSU-Next/commits/dev" | jq -r '.sha'
           }
@@ -61,43 +49,44 @@ jobs:
           {
             echo "# Commit Status Report"
             echo ""
-            echo "This report shows the pinned commit from this repository and the latest upstream commit for each supported SUSFS branch plus KernelSU-Next."
+            echo "This report shows the latest upstream commit for each supported SUSFS branch plus KernelSU-Next."
             echo ""
           } >> "$summary_file"
 
           {
             echo "## SUSFS"
             echo ""
-            echo "| Branch | Current Commit | Current Message | Latest Commit | Latest Message |"
-            echo "| --- | --- | --- | --- | --- |"
+            echo "| Branch | Latest Commit | Latest Message |"
+            echo "| --- | --- | --- |"
           } >> "$summary_file"
 
-          while IFS= read -r branch; do
-            current_commit="$(jq -r --arg key "$branch" '.susfs[$key]' "$COMMITS_JSON")"
+          SUSFS_BRANCHES=(
+            "gki-android12-5.10"
+            "gki-android13-5.10"
+            "gki-android13-5.15"
+            "gki-android14-5.15"
+            "gki-android14-6.1"
+            "gki-android15-6.6"
+            "gki-android16-6.12"
+          )
+
+          for branch in "${SUSFS_BRANCHES[@]}"; do
             latest_commit="$(gitlab_latest_commit "$branch")"
-            current_message="$(gitlab_commit_message "$current_commit")"
             latest_message="$(gitlab_latest_message "$branch")"
-
-            current_message="$(sanitize_cell "$current_message")"
             latest_message="$(sanitize_cell "$latest_message")"
-
-            printf '| %s | %s | %s | %s | %s |\n' "$branch" "$current_commit" "$current_message" "$latest_commit" "$latest_message" >> "$summary_file"
-          done < <(jq -r '.susfs | keys[]' "$COMMITS_JSON" | sort)
+            printf '| %s | %s | %s |\n' "$branch" "$latest_commit" "$latest_message" >> "$summary_file"
+          done
 
           {
             echo ""
             echo "## KernelSU-Next"
             echo ""
-            echo "| Branch | Current Commit | Current Message | Latest Commit | Latest Message |"
-            echo "| --- | --- | --- | --- | --- |"
+            echo "| Branch | Latest Commit | Latest Message |"
+            echo "| --- | --- | --- |"
           } >> "$summary_file"
 
-          current_kernelsu_commit="$(jq -r '.kernelsu.dev' "$COMMITS_JSON")"
           latest_kernelsu_commit="$(github_latest_commit)"
-          current_kernelsu_message="$(github_commit_message "$current_kernelsu_commit")"
           latest_kernelsu_message="$(github_latest_message)"
-
-          current_kernelsu_message="$(sanitize_cell "$current_kernelsu_message")"
           latest_kernelsu_message="$(sanitize_cell "$latest_kernelsu_message")"
 
-          printf '| %s | %s | %s | %s | %s |\n' "dev" "$current_kernelsu_commit" "$current_kernelsu_message" "$latest_kernelsu_commit" "$latest_kernelsu_message" >> "$summary_file"
+          printf '| %s | %s | %s |\n' "dev" "$latest_kernelsu_commit" "$latest_kernelsu_message" >> "$summary_file"

+ 54 - 49
.github/workflows/main.yml

@@ -44,10 +44,16 @@ on:
           - NONE
           - FULL
         default: FULL
-      use_latest_commits:
-        description: "Use branch tip for KernelSU and SUSFS instead of pinned commits"
-        type: boolean
-        default: true
+      ksu_branch:
+        description: "KernelSU branch or commit (empty = latest dev branch tip)"
+        type: string
+        required: false
+        default: ""
+      susfs_commit:
+        description: "SUSFS commit hash (empty = latest on auto-derived gki-{version} branch)"
+        type: string
+        required: false
+        default: ""
       test_release_notes:
         description: "Test release notes only"
         type: boolean
@@ -60,7 +66,8 @@ jobs:
     with:
       config_file: .github/config/android12-5.10.json
       feature_set: ${{ inputs.feature_set || 'FULL' }}
-      use_latest_commits: ${{ inputs.use_latest_commits }}
+      ksu_branch: ${{ inputs.ksu_branch }}
+      susfs_commit: ${{ inputs.susfs_commit }}
     secrets: inherit
 
   build-android13-5-10:
@@ -69,7 +76,8 @@ jobs:
     with:
       config_file: .github/config/android13-5.10.json
       feature_set: ${{ inputs.feature_set || 'FULL' }}
-      use_latest_commits: ${{ inputs.use_latest_commits }}
+      ksu_branch: ${{ inputs.ksu_branch }}
+      susfs_commit: ${{ inputs.susfs_commit }}
     secrets: inherit
 
   build-android13-5-15:
@@ -78,7 +86,8 @@ jobs:
     with:
       config_file: .github/config/android13-5.15.json
       feature_set: ${{ inputs.feature_set || 'FULL' }}
-      use_latest_commits: ${{ inputs.use_latest_commits }}
+      ksu_branch: ${{ inputs.ksu_branch }}
+      susfs_commit: ${{ inputs.susfs_commit }}
     secrets: inherit
 
   build-android14-5-15:
@@ -87,7 +96,8 @@ jobs:
     with:
       config_file: .github/config/android14-5.15.json
       feature_set: ${{ inputs.feature_set || 'FULL' }}
-      use_latest_commits: ${{ inputs.use_latest_commits }}
+      ksu_branch: ${{ inputs.ksu_branch }}
+      susfs_commit: ${{ inputs.susfs_commit }}
     secrets: inherit
 
   build-android14-6-1:
@@ -96,7 +106,8 @@ jobs:
     with:
       config_file: .github/config/android14-6.1.json
       feature_set: ${{ inputs.feature_set || 'FULL' }}
-      use_latest_commits: ${{ inputs.use_latest_commits }}
+      ksu_branch: ${{ inputs.ksu_branch }}
+      susfs_commit: ${{ inputs.susfs_commit }}
     secrets: inherit
 
   build-android15-6-6:
@@ -105,7 +116,8 @@ jobs:
     with:
       config_file: .github/config/android15-6.6.json
       feature_set: ${{ inputs.feature_set || 'FULL' }}
-      use_latest_commits: ${{ inputs.use_latest_commits }}
+      ksu_branch: ${{ inputs.ksu_branch }}
+      susfs_commit: ${{ inputs.susfs_commit }}
     secrets: inherit
 
   build-android16-6-12:
@@ -114,7 +126,8 @@ jobs:
     with:
       config_file: .github/config/android16-6.12.json
       feature_set: ${{ inputs.feature_set || 'FULL' }}
-      use_latest_commits: ${{ inputs.use_latest_commits }}
+      ksu_branch: ${{ inputs.ksu_branch }}
+      susfs_commit: ${{ inputs.susfs_commit }}
     secrets: inherit
 
   rej:
@@ -232,7 +245,8 @@ jobs:
           echo "# 📋 Workflow Build Summary"
           echo
           echo "**Feature Set:** ${{ inputs.feature_set }}"
-          echo "**Use Latest Commits:** ${{ inputs.use_latest_commits }}"
+          echo "**KSU Branch:** ${{ inputs.ksu_branch || 'latest dev' }}"
+          echo "**SUSFS Commit:** ${{ inputs.susfs_commit || 'latest' }}"
           echo
           echo "---"
           echo
@@ -259,37 +273,33 @@ jobs:
     env:
       GH_TOKEN: ${{ github.token }}
       RELEASE_NOTES: .github/config/RELEASE_NOTES.md
-      COMMITS_JSON: .github/config/commits.json
     steps:
     - name: Checkout code
       uses: actions/checkout@v5
 
     - name: Extract KernelSU Version Info
       id: ksu_version
-      env:
-        COMMITS_JSON_PATH: ${{ env.COMMITS_JSON }}
       run: |
         set -euo pipefail
 
-        KSUN_BRANCH="dev"
-
-        if [ "${{ inputs.use_latest_commits }}" = "true" ]; then
-          echo "Cloning KernelSU-Next from full branch tip: $KSUN_BRANCH"
-          git clone --branch "$KSUN_BRANCH" https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
-        else
-          echo "Cloning KernelSU-Next from branch: $KSUN_BRANCH"
-          git clone --depth=1 --branch "$KSUN_BRANCH" https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
+        KSU_INPUT="${{ inputs.ksu_branch }}"
+        if [ -z "$KSU_INPUT" ]; then
+          KSU_INPUT="dev"
         fi
 
-        cd /tmp/kernelsu-next
-
-        if [ "${{ inputs.use_latest_commits }}" = "true" ]; then
+        # Try as branch first, fall back to commit
+        if git ls-remote --heads https://github.com/KernelSU-Next/KernelSU-Next.git "$KSU_INPUT" | grep -q .; then
+          echo "Cloning KernelSU-Next from branch: $KSU_INPUT"
+          git clone --branch "$KSU_INPUT" https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
+          cd /tmp/kernelsu-next
           KSUN_COMMIT=$(git rev-parse HEAD)
         else
-          KSUN_COMMIT=$(jq -er '.kernelsu.dev' "$COMMITS_JSON_PATH")
-          echo "Checking out commit: $KSUN_COMMIT"
-          git fetch --depth=50 origin "$KSUN_COMMIT"
-          git checkout "$KSUN_COMMIT"
+          echo "Cloning KernelSU-Next from dev branch, then checking out commit: $KSU_INPUT"
+          git clone --branch dev https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
+          cd /tmp/kernelsu-next
+          git fetch --depth=50 origin "$KSU_INPUT"
+          git checkout "$KSU_INPUT"
+          KSUN_COMMIT="$KSU_INPUT"
         fi
 
         COMMITS_COUNT=$(git rev-list --count HEAD)
@@ -351,7 +361,6 @@ jobs:
     env:
       GH_TOKEN: ${{ github.token }}
       RELEASE_NOTES: .github/config/RELEASE_NOTES.md
-      COMMITS_JSON: .github/config/commits.json
     outputs:
       new_tag: ${{ steps.tag.outputs.new_tag }}
     steps:
@@ -452,31 +461,27 @@ jobs:
 
     - name: Extract KernelSU Version Info
       id: ksu_version
-      env:
-        COMMITS_JSON_PATH: ${{ env.COMMITS_JSON }}
       run: |
         set -euo pipefail
 
-        KSUN_BRANCH="dev"
-
-        if [ "${{ inputs.use_latest_commits }}" = "true" ]; then
-          echo "Cloning KernelSU-Next from full branch tip: $KSUN_BRANCH"
-          git clone --branch "$KSUN_BRANCH" https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
-        else
-          echo "Cloning KernelSU-Next from branch: $KSUN_BRANCH"
-          git clone --depth=1 --branch "$KSUN_BRANCH" https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
+        KSU_INPUT="${{ inputs.ksu_branch }}"
+        if [ -z "$KSU_INPUT" ]; then
+          KSU_INPUT="dev"
         fi
 
-        cd /tmp/kernelsu-next
-
-        if [ "${{ inputs.use_latest_commits }}" = "true" ]; then
+        # Try as branch first, fall back to commit
+        if git ls-remote --heads https://github.com/KernelSU-Next/KernelSU-Next.git "$KSU_INPUT" | grep -q .; then
+          echo "Cloning KernelSU-Next from branch: $KSU_INPUT"
+          git clone --branch "$KSU_INPUT" https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
+          cd /tmp/kernelsu-next
           KSUN_COMMIT=$(git rev-parse HEAD)
         else
-          # Extract KernelSU commit and branch from commits config
-          KSUN_COMMIT=$(jq -er '.kernelsu.dev' "$COMMITS_JSON_PATH")
-          echo "Checking out commit: $KSUN_COMMIT"
-          git fetch --depth=50 origin "$KSUN_COMMIT"
-          git checkout "$KSUN_COMMIT"
+          echo "Cloning KernelSU-Next from dev branch, then checking out commit: $KSU_INPUT"
+          git clone --branch dev https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
+          cd /tmp/kernelsu-next
+          git fetch --depth=50 origin "$KSU_INPUT"
+          git checkout "$KSU_INPUT"
+          KSUN_COMMIT="$KSU_INPUT"
         fi
 
         # Extract version info

+ 11 - 5
.github/workflows/prepare.yml

@@ -11,11 +11,16 @@ on:
         description: "Feature Set"
         required: false
         type: string
-      use_latest_commits:
-        description: "Use branch tip for KernelSU and SUSFS instead of pinned commits"
+      ksu_branch:
+        description: "KernelSU branch or commit (empty = latest dev)"
         required: false
-        type: boolean
-        default: true
+        type: string
+        default: ""
+      susfs_commit:
+        description: "SUSFS commit hash (empty = latest on auto-derived branch)"
+        required: false
+        type: string
+        default: ""
 
 jobs:
   generate-matrix:
@@ -87,5 +92,6 @@ jobs:
       os_patch_level: ${{ matrix.os_patch_level }}
       variant: ${{ matrix.variant }}
       feature_set: ${{ inputs.feature_set }}
-      use_latest_commits: ${{ inputs.use_latest_commits }}
+      ksu_branch: ${{ inputs.ksu_branch }}
+      susfs_commit: ${{ inputs.susfs_commit }}
     secrets: inherit