build-kernel-release.yml 15 KB

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