build-kernel-release.yml 12 KB

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