build-kernel-release.yml 12 KB

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