action.yml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. name: Setup Wild KSU
  2. description: Download and configure Wild KSU with version tracking
  3. inputs:
  4. ksu_commit:
  5. description: "KernelSU-Next ref/commit (optional, defaults to dev)"
  6. required: false
  7. type: string
  8. default: ""
  9. runs:
  10. using: composite
  11. steps:
  12. - name: Download Wild KSU
  13. shell: bash
  14. working-directory: ${{ github.workspace }}/kernel
  15. run: |
  16. set -euo pipefail
  17. TARGET_REF="${{ inputs.ksu_commit }}"
  18. if [ -z "$TARGET_REF" ]; then TARGET_REF="dev"; fi
  19. curl -LSs "https://raw.githubusercontent.com/KernelSU-Next/KernelSU-Next/dev/kernel/setup.sh" | bash -s dev
  20. if [ "$TARGET_REF" != "dev" ]; then
  21. cd KernelSU-Next
  22. if git rev-parse --is-shallow-repository >/dev/null 2>&1 && git rev-parse --is-shallow-repository | grep -q true; then
  23. git fetch --unshallow --tags --prune || true
  24. fi
  25. git fetch --all --tags --prune
  26. if git checkout "$TARGET_REF" 2>/dev/null; then
  27. :
  28. elif git checkout "origin/$TARGET_REF" 2>/dev/null; then
  29. :
  30. elif git checkout "refs/tags/$TARGET_REF" 2>/dev/null; then
  31. :
  32. else
  33. echo "Error: could not checkout KernelSU-Next ref/commit/tag: $TARGET_REF"
  34. exit 1
  35. fi
  36. cd "$GITHUB_WORKSPACE/kernel"
  37. fi
  38. cd KernelSU-Next/kernel
  39. COMMITS_COUNT=$(/usr/bin/git rev-list --count HEAD)
  40. BASE_VERSION=30000
  41. KSU_VERSION=$(expr $COMMITS_COUNT "+" $BASE_VERSION)
  42. sed -i "s/^KSU_VERSION_FALLBACK := 1$/KSU_VERSION_FALLBACK := ${KSU_VERSION}/" Kbuild
  43. KSU_GIT_TAG="$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.1")"
  44. sed -i "s/^KSU_VERSION_TAG_FALLBACK := v0.0.1$/KSU_VERSION_TAG_FALLBACK := ${KSU_GIT_TAG}/" Kbuild
  45. - name: Enable KernelSU Config
  46. shell: bash
  47. working-directory: ${{ github.workspace }}/kernel
  48. run: |
  49. cat >> "${{ github.workspace }}/wild_gki.fragment" << 'EOF'
  50. # KernelSU Configuration
  51. CONFIG_KSU=y
  52. EOF
  53. - name: Extract KSU Version Info
  54. id: ksu-version
  55. shell: bash
  56. working-directory: ${{ github.workspace }}/kernel/KernelSU-Next
  57. run: |
  58. # Extract and export KSU version info
  59. KSU_GIT_VERSION=$(git rev-list --count HEAD 2>/dev/null)
  60. KSU_GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null)
  61. KSU_COMMIT=$(git rev-parse --short HEAD 2>/dev/null)
  62. KSU_VERSION=$((30000 + KSU_GIT_VERSION))
  63. echo "KSU_GIT_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
  64. echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
  65. echo "KSU_COMMIT=$KSU_COMMIT" >> $GITHUB_ENV