build-kernel-release.yml 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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: false
  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. trigger-release:
  109. runs-on: ubuntu-latest
  110. needs:
  111. - build-kernel-a12-5-10
  112. - build-kernel-a13-5-10
  113. - build-kernel-a13-5-15
  114. - build-kernel-a14-5-15
  115. - build-kernel-a14-6-1
  116. - build-kernel-a15-6-6
  117. if: ${{ inputs.make_release }}
  118. env:
  119. REPO_OWNER: WildPlusKernel
  120. REPO_NAME: GKI_KernelSU_SUSFS
  121. GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
  122. RELEASE_NAME: "*TEST BUILD* GKI Kernels With KernelSU Next & SUSFS v1.5.5 *TEST BUILD*"
  123. RELEASE_NOTES: |
  124. This release contains KernelSU Next and SUSFS v1.5.5
  125. Module:
  126. -> https://github.com/sidex15/ksu_module_susfs
  127. Features:
  128. [+] KernelSU
  129. [+] SUSFS v1.5.5
  130. [+] Wireguard Support
  131. [+] Maphide LineageOS Detections
  132. [+] Futile Maphide for jit-zygote-cache Detections
  133. [+] Magic Mount Support
  134. steps:
  135. # Checkout the code
  136. - name: Checkout code
  137. uses: actions/checkout@v3
  138. - name: Determine the branch for KernelSU-Next
  139. run: |
  140. # Determine the branch based on user input
  141. if [[ "${{ inputs.kernelsu_branch }}" == "Stable" ]]; then
  142. BRANCH="Stable"
  143. elif [[ "${{ inputs.kernelsu_branch }}" == "Dev" ]]; then
  144. BRANCH="next"
  145. elif [[ "${{ inputs.kernelsu_branch }}" == "Other" && -n "${{ inputs.kernelsu_branch_other }}" ]]; then
  146. BRANCH="${{ inputs.kernelsu_branch_other }}"
  147. else
  148. echo "Error: Custom branch not provided for 'Other'" >&2
  149. exit 1
  150. fi
  151. # Store the selected branch in GITHUB_ENV
  152. echo "KSU_BRANCH=$BRANCH" >> $GITHUB_ENV
  153. - name: Get commit hash or tag and generate URL for KernelSU-Next
  154. run: |
  155. if [ "${{ inputs.kernelsu_variant }}" == "Official" ]; then
  156. echo "This is the Official variant"
  157. REPO_URL="https://github.com/tiann/KernelSU.git"
  158. REPO_URL2="tiann/KernelSU"
  159. elif [ "${{ inputs.kernelsu_variant }}" == "Next" ]; then
  160. echo "This is the Next variant"
  161. REPO_URL="https://github.com/rifsxd/KernelSU-Next.git"
  162. REPO_URL2="rifsxd/KernelSU-Next"
  163. elif [ "${{ inputs.kernelsu_variant }}" == "MKSU" ]; then
  164. echo "This is the MKSU variant"
  165. REPO_URL="https://github.com/5ec1cff/KernelSU.git"
  166. REPO_URL2="5ec1cff/KernelSU"
  167. else
  168. echo "Unknown variant"
  169. fi
  170. BRANCH="${{ env.KSU_BRANCH }}"
  171. if [[ "$BRANCH" == "Stable" || ]]; then
  172. # Fetch the latest tag
  173. TAG=$(git ls-remote --tags --sort=-v:refname $REPO_URL | grep -o 'refs/tags/.*' | cut -d'/' -f3 | head -n1)
  174. if [[ -z "$TAG" ]]; then
  175. echo "Error: Could not fetch latest tag for KernelSU" >&2
  176. exit 1
  177. fi
  178. KSU_REF=$TAG
  179. KSU_URL="https://github.com/$REPO_URL2/releases/tag/$TAG"
  180. elif [[ "$BRANCH" == "Dev" ]]; then
  181. # Fetch the latest commit from "next" branch
  182. COMMIT_HASH=$(git ls-remote $REPO_URL refs/heads/$BRANCH | awk '{ print $1 }')
  183. if [[ -z "$COMMIT_HASH" ]]; then
  184. echo "Error: Could not fetch latest commit for KernelSU-Next Dev" >&2
  185. exit 1
  186. fi
  187. KSU_REF=$COMMIT_HASH
  188. KSU_URL="https://github.com/$REPO_URL2/commit/$COMMIT_HASH"
  189. else
  190. # Fetch the specific tag for the custom branch
  191. TAG=$BRANCH
  192. if git ls-remote --tags $REPO_URL | grep -q "refs/tags/$TAG"; then
  193. KSU_REF=$TAG
  194. KSU_URL="https://github.com/$REPO_URL2/releases/tag/$TAG"
  195. else
  196. echo "Error: Specified tag '$TAG' not found in KernelSU-Next" >&2
  197. exit 1
  198. fi
  199. fi
  200. # Echo the values to GitHub environment for later use
  201. echo "KSU_REF=$KSU_REF" >> $GITHUB_ENV
  202. echo "KSU_URL=$KSU_URL" >> $GITHUB_ENV
  203. echo "KernelSU Reference: $KSU_REF"
  204. echo "KernelSU URL: $KSU_URL"
  205. - name: Get commit hashes and generate commit URLs
  206. run: |
  207. GITLAB_OWNER="simonpunk"
  208. GITLAB_REPO="susfs4ksu"
  209. declare -A BRANCH_MAP=(
  210. ["gki_android12_5_10"]="gki-android12-5.10"
  211. ["gki_android13_5_10"]="gki-android13-5.10"
  212. ["gki_android13_5_15"]="gki-android13-5.15"
  213. ["gki_android14_5_15"]="gki-android14-5.15"
  214. ["gki_android14_6_1"]="gki-android14-6.1"
  215. )
  216. for var_name in "${!BRANCH_MAP[@]}"; do
  217. branch_name="${BRANCH_MAP[$var_name]}"
  218. COMMIT_HASH=$(git ls-remote https://gitlab.com/$GITLAB_OWNER/$GITLAB_REPO.git refs/heads/$branch_name | awk '{ print $1 }')
  219. if [[ -n "$COMMIT_HASH" ]]; then
  220. COMMIT_URL="https://gitlab.com/$GITLAB_OWNER/$GITLAB_REPO/-/commit/$COMMIT_HASH"
  221. echo "$branch_name Commit: $COMMIT_HASH"
  222. echo "$branch_name Commit URL: $COMMIT_URL"
  223. # Store commit hash and commit URL in GitHub environment
  224. echo "COMMIT_HASH_${var_name}=$COMMIT_HASH" >> "$GITHUB_ENV"
  225. echo "COMMIT_URL_${var_name}=$COMMIT_URL" >> "$GITHUB_ENV"
  226. fi
  227. done
  228. - name: Append Commit Hashes & Links to `RELEASE_NOTES` & Append KernelSU-Next Reference to `RELEASE_NOTES`
  229. run: |
  230. if [ "${{ inputs.kernelsu_variant }}" == "Official" ]; then
  231. echo "This is the Official variant"
  232. echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
  233. echo "$RELEASE_NOTES" >> $GITHUB_ENV
  234. echo "Official Manager:" >> $GITHUB_ENV
  235. echo "https://github.com/tiann/KernelSU" >> $GITHUB_ENV
  236. echo "EOF" >> $GITHUB_ENV
  237. elif [ "${{ inputs.kernelsu_variant }}" == "Next" ]; then
  238. echo "This is the Next variant"
  239. echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
  240. echo "$RELEASE_NOTES" >> $GITHUB_ENV
  241. echo "Next Manager:" >> $GITHUB_ENV
  242. echo "https://github.com/rifsxd/KernelSU-Next" >> $GITHUB_ENV
  243. echo "EOF" >> $GITHUB_ENV
  244. elif [ "${{ inputs.kernelsu_variant }}" == "MKSU" ]; then
  245. echo "This is the MKSU variant"
  246. echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
  247. echo "$RELEASE_NOTES" >> $GITHUB_ENV
  248. echo "MKSU Manager:" >> $GITHUB_ENV
  249. echo "https://github.com/5ec1cff/KernelSU" >> $GITHUB_ENV
  250. echo "EOF" >> $GITHUB_ENV
  251. else
  252. echo "Unknown variant"
  253. fi
  254. - name: Append Commit Hashes & Links to `RELEASE_NOTES` & Append KernelSU-Next Reference to `RELEASE_NOTES`
  255. run: |
  256. echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
  257. echo "$RELEASE_NOTES" >> $GITHUB_ENV
  258. echo "" >> $GITHUB_ENV
  259. echo "LTO: ${{ inputs.lto_type }}" >> $GITHUB_ENV
  260. echo "" >> $GITHUB_ENV
  261. echo "Commit Hashes & Links:" >> $GITHUB_ENV
  262. echo "KernelSU:" >> $GITHUB_ENV
  263. echo "${{ inputs.kernelsu_variant }}-${{ inputs.kernelsu_branch }}: [$KSU_REF]($KSU_URL)" >> $GITHUB_ENV
  264. echo "SUSFS4KSU:" >> $GITHUB_ENV
  265. echo "gki-android12-5.10: [$COMMIT_HASH_gki_android12_5_10]($COMMIT_URL_gki_android12_5_10)" >> $GITHUB_ENV
  266. echo "gki-android13-5.10: [$COMMIT_HASH_gki_android13_5_10]($COMMIT_URL_gki_android13_5_10)" >> $GITHUB_ENV
  267. echo "gki-android13-5.15: [$COMMIT_HASH_gki_android13_5_15]($COMMIT_URL_gki_android13_5_15)" >> $GITHUB_ENV
  268. echo "gki-android14-5.15: [$COMMIT_HASH_gki_android14_5_15]($COMMIT_URL_gki_android14_5_15)" >> $GITHUB_ENV
  269. echo "gki-android14-6.1: [$COMMIT_HASH_gki_android14_6_1]($COMMIT_URL_gki_android14_6_1)" >> $GITHUB_ENV
  270. echo "" >> $GITHUB_ENV
  271. echo "EOF" >> $GITHUB_ENV
  272. # Get the Latest Tag from GitHub
  273. - name: Generate and Create New Tag
  274. run: |
  275. # Fetch the latest tag from GitHub (this is the latest tag based on the GitHub API)
  276. LATEST_TAG=$(gh api repos/$REPO_OWNER/$REPO_NAME/tags --jq '.[0].name')
  277. if [ -z "$LATEST_TAG" ]; then
  278. LATEST_TAG="v1.5.4-0"
  279. fi
  280. NEW_TAG=$(echo "$LATEST_TAG" | awk -F- '{suffix=$2; if (!suffix) suffix=0; suffix++; printf "%s-%d", $1, suffix}')
  281. # Output the new tag to be used
  282. echo "New tag: $NEW_TAG"
  283. # Set the new tag as an environment variable to be used in later steps
  284. echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
  285. # Create the tag in the repository
  286. git tag $NEW_TAG
  287. git push origin $NEW_TAG
  288. # Download Artifacts for A12 (Only if A12 Build is successful or input is true or empty)
  289. - name: Download Artifacts
  290. uses: actions/download-artifact@v4
  291. with:
  292. path: ./downloaded-artifacts
  293. # Create GitHub Release and upload files if make_release is true
  294. - name: Create GitHub Release
  295. uses: actions/create-release@v1
  296. with:
  297. tag_name: ${{ env.NEW_TAG }} # Use the generated tag for the release
  298. prerelease: true # Mark the release as a pre-release
  299. release_name: ${{ env.RELEASE_NAME }} # Pass the RELEASE_NAME to the action
  300. body: ${{ env.RELEASE_NOTES }} # Pass the RELEASE_NOTES to the action
  301. - name: Upload Release Assets Dynamically
  302. run: |
  303. # Loop through all files in the downloaded-artifacts directory
  304. for file in ./downloaded-artifacts/kernel-*/*; do
  305. # Skip directories
  306. if [ -d "$file" ]; then
  307. continue
  308. fi
  309. # Upload the file to the GitHub release
  310. echo "Uploading $file..."
  311. gh release upload ${{ env.NEW_TAG }} "$file"
  312. done
  313. # Display Files Uploaded
  314. - name: Display Files Uploaded
  315. run: |
  316. echo "GitHub release created with the following files:"
  317. ls ./downloaded-artifacts/**/*