action.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. name: Fetch Latest Commits
  2. description: "Fetches the latest commit hashes for KernelSU-Next, AnyKernel3, Kernel Patches, SUSFS, and BBG"
  3. inputs:
  4. ksu_commit:
  5. description: "Optional: Specific KernelSU-Next ref/commit to use"
  6. required: false
  7. default: ""
  8. outputs:
  9. ksu_commit:
  10. description: "KernelSU-Next Commit"
  11. value: ${{ steps.commits.outputs.ksu_commit }}
  12. ksu_tag:
  13. description: "KernelSU-Next Tag (best effort)"
  14. value: ${{ steps.commits.outputs.ksu_tag }}
  15. anykernel_commit:
  16. description: "AnyKernel3 Commit"
  17. value: ${{ steps.commits.outputs.anykernel_commit }}
  18. patches_commit:
  19. description: "Kernel Patches Commit"
  20. value: ${{ steps.commits.outputs.patches_commit }}
  21. susfs_commit:
  22. description: "SUSFS Commit (Map)"
  23. value: ${{ steps.commits.outputs.susfs_commit }}
  24. bbg_commit:
  25. description: "BBG Commit"
  26. value: ${{ steps.commits.outputs.bbg_commit }}
  27. runs:
  28. using: "composite"
  29. steps:
  30. - name: Get Latest Commits
  31. id: commits
  32. shell: bash
  33. run: |
  34. # Helper to get latest commit from remote without cloning full repo
  35. get_commit() {
  36. git ls-remote "$1" "$2" | awk '{print $1}'
  37. }
  38. get_tag_for_commit() {
  39. repo="$1"
  40. commit="$2"
  41. git ls-remote --tags "$repo" | awk -v c="$commit" '$1==c && $2 ~ /^refs\/tags\// {print $2}' \
  42. | sed -E 's#^refs/tags/##; s#\^\{\}$##' \
  43. | sort -V \
  44. | tail -n 1
  45. }
  46. echo "Fetching latest commits..."
  47. # KernelSU-Next
  48. if [ -n "${{ inputs.ksu_commit }}" ]; then
  49. input_ref="${{ inputs.ksu_commit }}"
  50. resolved_commit="$(get_commit "https://github.com/KernelSU-Next/KernelSU-Next.git" "$input_ref")"
  51. if [ -z "$resolved_commit" ]; then
  52. resolved_commit="$(get_commit "https://github.com/KernelSU-Next/KernelSU-Next.git" "refs/heads/$input_ref")"
  53. fi
  54. if [ -z "$resolved_commit" ]; then
  55. resolved_commit="$(get_commit "https://github.com/KernelSU-Next/KernelSU-Next.git" "refs/tags/$input_ref")"
  56. fi
  57. if [ -n "$resolved_commit" ]; then
  58. ksu_commit="$resolved_commit"
  59. else
  60. # If resolution failed, assume input is a commit SHA
  61. ksu_commit="$input_ref"
  62. fi
  63. echo "Using provided KernelSU-Next commit: $ksu_commit"
  64. else
  65. ksu_commit=$(get_commit "https://github.com/KernelSU-Next/KernelSU-Next.git" "refs/heads/dev")
  66. echo "KernelSU-Next: $ksu_commit"
  67. fi
  68. echo "ksu_commit=$ksu_commit" >> $GITHUB_OUTPUT
  69. KSUN_TAG="$(get_tag_for_commit "https://github.com/KernelSU-Next/KernelSU-Next.git" "$ksu_commit")"
  70. echo "KernelSU-Next Tag: ${KSUN_TAG:-None}"
  71. echo "ksu_tag=$KSUN_TAG" >> $GITHUB_OUTPUT
  72. # AnyKernel3
  73. AK3_COMMIT=$(get_commit "https://github.com/WildKernels/AnyKernel3.git" "refs/heads/gki-2.0")
  74. echo "AnyKernel3: $AK3_COMMIT"
  75. echo "anykernel_commit=$AK3_COMMIT" >> $GITHUB_OUTPUT
  76. # Kernel Patches
  77. PATCHES_COMMIT=$(get_commit "https://github.com/WildKernels/kernel_patches.git" "HEAD")
  78. echo "Kernel Patches: $PATCHES_COMMIT"
  79. echo "patches_commit=$PATCHES_COMMIT" >> $GITHUB_OUTPUT
  80. # SUSFS (using gitlab) - Fetch all relevant branches
  81. SUSFS_REPO="https://gitlab.com/simonpunk/susfs4ksu.git"
  82. echo "Fetching SUSFS commits for all branches..."
  83. # We need to construct a JSON object or a simple string map
  84. # Format: branch1:commit1,branch2:commit2,...
  85. BRANCHES=(
  86. "gki-android12-5.10"
  87. "gki-android13-5.10"
  88. "gki-android13-5.15"
  89. "gki-android14-5.15"
  90. "gki-android14-6.1"
  91. "gki-android15-6.6"
  92. "gki-android16-6.12"
  93. )
  94. SUSFS_MAP=""
  95. for branch in "${BRANCHES[@]}"; do
  96. COMMIT=$(get_commit "$SUSFS_REPO" "refs/heads/$branch")
  97. if [ -n "$COMMIT" ]; then
  98. echo " $branch: $COMMIT"
  99. if [ -z "$SUSFS_MAP" ]; then
  100. SUSFS_MAP="$branch:$COMMIT"
  101. else
  102. SUSFS_MAP="$SUSFS_MAP,$branch:$COMMIT"
  103. fi
  104. else
  105. echo " $branch: Not found"
  106. fi
  107. done
  108. echo "susfs_commit=$SUSFS_MAP" >> $GITHUB_OUTPUT
  109. # BBG
  110. BBG_COMMIT=$(get_commit "https://github.com/vc-teahouse/Baseband-guard.git" "refs/heads/main")
  111. echo "BBG: $BBG_COMMIT"
  112. echo "bbg_commit=$BBG_COMMIT" >> $GITHUB_OUTPUT