build-kernel-release.yml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. name: Build and Release GKI Kernels
  2. permissions:
  3. contents: write # Allow writing to repository contents (for pushing tags)
  4. actions: write # Allows triggering actions
  5. on:
  6. workflow_dispatch:
  7. inputs:
  8. make_release:
  9. description: 'Do you want to create a release?'
  10. required: true
  11. type: boolean
  12. default: true
  13. runner:
  14. description: "Choose runner"
  15. required: true
  16. type: choice
  17. options:
  18. - ubuntu-22.04
  19. - ubuntu-22.04-local
  20. default: ubuntu-22.04
  21. kernelsu_variant:
  22. description: "Choose KernelSU"
  23. required: true
  24. type: choice
  25. options:
  26. - Official
  27. - Next
  28. - MKSU
  29. default: Next
  30. kernelsu_branch:
  31. description: "Choose ksu branch"
  32. required: true
  33. type: choice
  34. options:
  35. - Stable
  36. - Dev
  37. - Other
  38. default: Stable
  39. kernelsu_branch_other:
  40. description: "If 'Other' is selected, specify your custom branch"
  41. required: false
  42. type: string # This input is required if 'Other' is chosen
  43. default: "" # Default is empty, but can be filled in if 'Other' is selected
  44. jobs:
  45. kernel-wsa:
  46. uses: ./.github/workflows/kernel-wsa.yml
  47. secrets: inherit
  48. with:
  49. runner: ${{ inputs.runner }}
  50. kernelsu_variant: ${{ inputs.kernelsu_variant }}
  51. kernelsu_branch: ${{ inputs.kernelsu_branch }}
  52. kernelsu_branch_other: ${{ inputs.kernelsu_branch_other }}
  53. trigger-release:
  54. runs-on: ubuntu-latest
  55. needs:
  56. - kernel-wsa
  57. if: ${{ inputs.make_release }}
  58. env:
  59. REPO_OWNER: WildPlusKernel
  60. REPO_NAME: GKI_KernelSU_SUSFS
  61. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  62. RELEASE_NAME: "*TEST BUILD* WSA Kernels With KernelSU-${{ inputs.kernelsu_variant }} ${{ inputs.kernelsu_branch }} & SUSFS v1.5.5 *TEST BUILD*"
  63. RELEASE_NOTES: |
  64. This release contains KernelSU-${{ inputs.kernelsu_variant }} ${{ inputs.kernelsu_branch }} and SUSFS v1.5.5
  65. Features:
  66. -> KernelSU-${{ inputs.kernelsu_variant }}-${{ inputs.kernelsu_branch }}
  67. -> SUSFS ඞ v1.5.5
  68. -> Wireguard Support
  69. -> Simple Maphide for LineageOS Detections
  70. -> Futile Maphide for jit-zygote-cache Detections
  71. -> Magic Mount Support
  72. Module:
  73. -> https://github.com/sidex15/ksu_module_susfs
  74. steps:
  75. # Checkout the code
  76. - name: Checkout code
  77. uses: actions/checkout@v3
  78. - name: Determine the branch for KernelSU-${{ inputs.kernelsu_variant }}
  79. if: ${{ inputs.kernelsu_branch == 'Dev' || inputs.kernelsu_variant == 'MKSU' }}
  80. run: |
  81. # Determine the branch based on user input
  82. if [[ "${{ inputs.kernelsu_variant }}" == "Official" || "${{ inputs.kernelsu_variant }}" == "MKSU" ]]; then
  83. BRANCH="main"
  84. elif [[ "${{ inputs.kernelsu_variant }}" == "Next" ]]; then
  85. BRANCH="next"
  86. elif [[ "${{ inputs.kernelsu_branch }}" == "Other" && -n "${{ inputs.kernelsu_branch_other }}" ]]; then
  87. BRANCH="${{ inputs.kernelsu_branch_other }}"
  88. else
  89. echo "Error: Custom branch not provided for 'Other'" >&2
  90. exit 1
  91. fi
  92. # Store the selected branch in GITHUB_ENV
  93. echo "KSU_BRANCH=$BRANCH" >> $GITHUB_ENV
  94. - name: Get commit hash or tag and generate URL for KernelSU-${{ inputs.kernelsu_variant }}
  95. run: |
  96. if [ "${{ inputs.kernelsu_variant }}" == "Official" ]; then
  97. echo "This is the Official variant"
  98. REPO_URL="https://github.com/tiann/KernelSU.git"
  99. REPO_URL2="tiann/KernelSU"
  100. elif [ "${{ inputs.kernelsu_variant }}" == "Next" ]; then
  101. echo "This is the Next variant"
  102. REPO_URL="https://github.com/rifsxd/KernelSU-Next.git"
  103. REPO_URL2="rifsxd/KernelSU-Next"
  104. elif [ "${{ inputs.kernelsu_variant }}" == "MKSU" ]; then
  105. echo "This is the MKSU variant"
  106. REPO_URL="https://github.com/5ec1cff/KernelSU.git"
  107. REPO_URL2="5ec1cff/KernelSU"
  108. else
  109. echo "Unknown variant"
  110. fi
  111. if [[ "${{ inputs.kernelsu_branch }}" == "Stable" && "${{ inputs.kernelsu_variant }}" != "MKSU" ]]; then
  112. # Fetch the latest tag
  113. TAG=$(git ls-remote --tags --sort=-v:refname $REPO_URL | grep -o 'refs/tags/.*' | cut -d'/' -f3 | head -n1)
  114. if [[ -z "$TAG" ]]; then
  115. echo "Error: Could not fetch latest tag for Stable" >&2
  116. exit 1
  117. fi
  118. KSU_REF=$TAG
  119. KSU_URL="https://github.com/$REPO_URL2/releases/tag/$TAG"
  120. elif [[ "${{ inputs.kernelsu_branch }}" == "Dev" || "${{ inputs.kernelsu_variant }}" == "MKSU" ]]; then
  121. # Fetch the latest commit from "next" branch
  122. COMMIT_HASH=$(git ls-remote $REPO_URL refs/heads/$KSU_BRANCH | awk '{ print $1 }')
  123. if [[ -z "$COMMIT_HASH" ]]; then
  124. echo "Error: Could not fetch latest commit for Dev" >&2
  125. exit 1
  126. fi
  127. KSU_REF=$COMMIT_HASH
  128. KSU_URL="https://github.com/$REPO_URL2/commit/$COMMIT_HASH"
  129. else
  130. # Fetch the specific tag
  131. TAG=${{ inputs.kernelsu_branch_other }}
  132. if git ls-remote --tags $REPO_URL | grep -q "refs/tags/$TAG"; then
  133. KSU_REF=$TAG
  134. KSU_URL="https://github.com/$REPO_URL2/releases/tag/$TAG"
  135. else
  136. echo "Error: Specified tag '$TAG' not found in KernelSU-Next" >&2
  137. exit 1
  138. fi
  139. fi
  140. # Echo the values to GitHub environment for later use
  141. echo "KSU_REF=$KSU_REF" >> $GITHUB_ENV
  142. echo "KSU_URL=$KSU_URL" >> $GITHUB_ENV
  143. echo "KernelSU Reference: $KSU_REF"
  144. echo "KernelSU URL: $KSU_URL"
  145. - name: Get commit hashes and generate commit URLs
  146. run: |
  147. GITLAB_OWNER="simonpunk"
  148. GITLAB_REPO="susfs4ksu"
  149. declare -A BRANCH_MAP=(
  150. ["gki_android12_5_10"]="gki-android12-5.10"
  151. ["gki_android13_5_10"]="gki-android13-5.10"
  152. ["gki_android13_5_15"]="gki-android13-5.15"
  153. ["gki_android14_5_15"]="gki-android14-5.15"
  154. ["gki_android14_6_1"]="gki-android14-6.1"
  155. )
  156. for var_name in "${!BRANCH_MAP[@]}"; do
  157. branch_name="${BRANCH_MAP[$var_name]}"
  158. COMMIT_HASH=$(git ls-remote https://gitlab.com/$GITLAB_OWNER/$GITLAB_REPO.git refs/heads/$branch_name | awk '{ print $1 }')
  159. if [[ -n "$COMMIT_HASH" ]]; then
  160. COMMIT_URL="https://gitlab.com/$GITLAB_OWNER/$GITLAB_REPO/-/commit/$COMMIT_HASH"
  161. echo "$branch_name Commit: $COMMIT_HASH"
  162. echo "$branch_name Commit URL: $COMMIT_URL"
  163. # Store commit hash and commit URL in GitHub environment
  164. echo "COMMIT_HASH_${var_name}=$COMMIT_HASH" >> "$GITHUB_ENV"
  165. echo "COMMIT_URL_${var_name}=$COMMIT_URL" >> "$GITHUB_ENV"
  166. fi
  167. done
  168. - name: Append Commit Hashes & Links to `RELEASE_NOTES` & Append KernelSU-Next Reference to `RELEASE_NOTES`
  169. run: |
  170. if [ "${{ inputs.kernelsu_variant }}" == "Official" ]; then
  171. echo "This is the Official variant"
  172. echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
  173. echo "$RELEASE_NOTES" >> $GITHUB_ENV
  174. echo "Official Manager:" >> $GITHUB_ENV
  175. echo "-> https://github.com/tiann/KernelSU" >> $GITHUB_ENV
  176. echo "EOF" >> $GITHUB_ENV
  177. elif [ "${{ inputs.kernelsu_variant }}" == "Next" ]; then
  178. echo "This is the Next variant"
  179. echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
  180. echo "$RELEASE_NOTES" >> $GITHUB_ENV
  181. echo "Next Manager:" >> $GITHUB_ENV
  182. echo "-> https://github.com/rifsxd/KernelSU-Next" >> $GITHUB_ENV
  183. echo "EOF" >> $GITHUB_ENV
  184. elif [ "${{ inputs.kernelsu_variant }}" == "MKSU" ]; then
  185. echo "This is the MKSU variant"
  186. echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
  187. echo "$RELEASE_NOTES" >> $GITHUB_ENV
  188. echo "MKSU Manager:" >> $GITHUB_ENV
  189. echo "-> https://github.com/5ec1cff/KernelSU" >> $GITHUB_ENV
  190. echo "EOF" >> $GITHUB_ENV
  191. else
  192. echo "Unknown variant"
  193. fi
  194. - name: Append Commit Hashes & Links to `RELEASE_NOTES` & Append KernelSU-Next Reference to `RELEASE_NOTES`
  195. run: |
  196. echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
  197. echo "$RELEASE_NOTES" >> $GITHUB_ENV
  198. echo "" >> $GITHUB_ENV
  199. echo "LTO: ${{ inputs.lto_type }}" >> $GITHUB_ENV
  200. echo "" >> $GITHUB_ENV
  201. echo "Commit Hashes and Links:" >> $GITHUB_ENV
  202. echo "KernelSU:" >> $GITHUB_ENV
  203. echo "${{ inputs.kernelsu_variant }}-${{ inputs.kernelsu_branch }}: [$KSU_REF]($KSU_URL)" >> $GITHUB_ENV
  204. echo "SUSFS4KSU:" >> $GITHUB_ENV
  205. echo "gki-android13-5.10: [$COMMIT_HASH_gki_android13_5_10]($COMMIT_URL_gki_android13_5_10)" >> $GITHUB_ENV
  206. echo "gki-android13-5.15: [$COMMIT_HASH_gki_android13_5_15]($COMMIT_URL_gki_android13_5_15)" >> $GITHUB_ENV
  207. echo "" >> $GITHUB_ENV
  208. echo "EOF" >> $GITHUB_ENV
  209. # Get the Latest Tag from GitHub
  210. - name: Generate and Create New Tag
  211. env:
  212. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  213. run: |
  214. # Fetch the latest tag from GitHub (this is the latest tag based on the GitHub API)
  215. LATEST_TAG=$(gh api repos/$REPO_OWNER/$REPO_NAME/tags --jq '.[0].name')
  216. if [ -z "$LATEST_TAG" ]; then
  217. LATEST_TAG="v1.5.5-r0"
  218. fi
  219. NEW_TAG=$(echo "$LATEST_TAG" | awk -F'-r' '{suffix=$2; if (!suffix) suffix=0; suffix++; printf "%s-r%d", $1, suffix}')
  220. # Output the new tag to be used
  221. echo "New tag: $NEW_TAG"
  222. # Set the new tag as an environment variable to be used in later steps
  223. echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
  224. # Create the tag in the repository
  225. git tag $NEW_TAG
  226. git push --tags
  227. # Download Artifacts for A12 (Only if A12 Build is successful or input is true or empty)
  228. - name: Download Artifacts
  229. uses: actions/download-artifact@v4
  230. with:
  231. path: ./downloaded-artifacts
  232. # Create GitHub Release and upload files if make_release is true
  233. - name: Create GitHub Release
  234. uses: actions/create-release@v1
  235. with:
  236. tag_name: ${{ env.NEW_TAG }} # Use the generated tag for the release
  237. prerelease: true # Mark the release as a pre-release
  238. release_name: ${{ env.RELEASE_NAME }} # Pass the RELEASE_NAME to the action
  239. body: ${{ env.RELEASE_NOTES }} # Pass the RELEASE_NOTES to the action
  240. - name: Upload Release Assets Dynamically
  241. run: |
  242. # Loop through all files in the downloaded-artifacts directory
  243. for file in ./downloaded-artifacts/kernel-*/*; do
  244. # Skip directories
  245. if [ -d "$file" ]; then
  246. continue
  247. fi
  248. # Upload the file to the GitHub release
  249. echo "Uploading $file..."
  250. gh release upload ${{ env.NEW_TAG }} "$file"
  251. done
  252. # Display Files Uploaded
  253. - name: Display Files Uploaded
  254. run: |
  255. echo "GitHub release created with the following files:"
  256. ls ./downloaded-artifacts/**/*
  257. - name: send telegram message on push
  258. env:
  259. TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
  260. TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
  261. TELEGRAM_MESSAGE_THREAD_ID: ${{ secrets.TELEGRAM_MESSAGE_THREAD_ID }}
  262. run: |
  263. curl -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" \
  264. -d "chat_id=$TELEGRAM_CHAT_ID" \
  265. -d "message_thread_id=$TELEGRAM_MESSAGE_THREAD_ID" \
  266. -d "text=Latest release:
  267. https://github.com/WildPlusKernel/GKI_KernelSU_SUSFS/releases/tag/${{ env.NEW_TAG }}
  268. ${{ env.RELEASE_NOTES }}"