main.yml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. name: Build Kernels
  2. permissions:
  3. contents: write
  4. actions: write
  5. on:
  6. workflow_dispatch:
  7. inputs:
  8. release_type:
  9. description: "Release Type"
  10. type: choice
  11. options:
  12. - Action
  13. - Pre-Release
  14. - Release
  15. default: Action
  16. kernel_build_version:
  17. description: "Kernel Version"
  18. type: choice
  19. options:
  20. - All
  21. - android12-5.10
  22. - android13-5.10
  23. - android13-5.15
  24. - android14-5.15
  25. - android14-6.1
  26. - android15-6.6
  27. - android16-6.12
  28. default: All
  29. feature_set:
  30. description: "Feature Set"
  31. type: choice
  32. options:
  33. - KSUN+SUSFS+BBG+NET+DS
  34. - KSUN+SUSFS+BBG
  35. - KSUN+SUSFS+NET
  36. - KSUN+SUSFS+DS
  37. - KSUN+SUSFS
  38. - KSUN+BBG
  39. - KSUN+NET
  40. - KSUN+DS
  41. - KSUN
  42. - NONE
  43. - FULL
  44. default: FULL
  45. use_repo:
  46. description: "Use repo for downloading kernel source"
  47. type: boolean
  48. default: true
  49. test_release_notes:
  50. description: "Test release notes only"
  51. type: boolean
  52. default: false
  53. jobs:
  54. build-android12-5-10:
  55. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android12-5.10') }}
  56. uses: ./.github/workflows/prepare.yml
  57. with:
  58. config_file: .github/config/android12-5.10.json
  59. feature_set: ${{ inputs.feature_set || 'FULL' }}
  60. use_repo: ${{ inputs.use_repo }}
  61. secrets: inherit
  62. build-android13-5-10:
  63. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android13-5.10') }}
  64. uses: ./.github/workflows/prepare.yml
  65. with:
  66. config_file: .github/config/android13-5.10.json
  67. feature_set: ${{ inputs.feature_set || 'FULL' }}
  68. use_repo: ${{ inputs.use_repo }}
  69. secrets: inherit
  70. build-android13-5-15:
  71. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android13-5.15') }}
  72. uses: ./.github/workflows/prepare.yml
  73. with:
  74. config_file: .github/config/android13-5.15.json
  75. feature_set: ${{ inputs.feature_set || 'FULL' }}
  76. use_repo: ${{ inputs.use_repo }}
  77. secrets: inherit
  78. build-android14-5-15:
  79. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android14-5.15') }}
  80. uses: ./.github/workflows/prepare.yml
  81. with:
  82. config_file: .github/config/android14-5.15.json
  83. feature_set: ${{ inputs.feature_set || 'FULL' }}
  84. use_repo: ${{ inputs.use_repo }}
  85. secrets: inherit
  86. build-android14-6-1:
  87. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android14-6.1') }}
  88. uses: ./.github/workflows/prepare.yml
  89. with:
  90. config_file: .github/config/android14-6.1.json
  91. feature_set: ${{ inputs.feature_set || 'FULL' }}
  92. use_repo: ${{ inputs.use_repo }}
  93. secrets: inherit
  94. build-android15-6-6:
  95. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android15-6.6') }}
  96. uses: ./.github/workflows/prepare.yml
  97. with:
  98. config_file: .github/config/android15-6.6.json
  99. feature_set: ${{ inputs.feature_set || 'FULL' }}
  100. use_repo: ${{ inputs.use_repo }}
  101. secrets: inherit
  102. build-android16-6-12:
  103. if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android16-6.12') }}
  104. uses: ./.github/workflows/prepare.yml
  105. with:
  106. config_file: .github/config/android16-6.12.json
  107. feature_set: ${{ inputs.feature_set || 'FULL' }}
  108. use_repo: ${{ inputs.use_repo }}
  109. secrets: inherit
  110. rej:
  111. if: ${{ !inputs.test_release_notes && always() }}
  112. runs-on: ubuntu-latest
  113. permissions:
  114. actions: read
  115. contents: read
  116. needs:
  117. - build-android12-5-10
  118. - build-android13-5-10
  119. - build-android13-5-15
  120. - build-android14-5-15
  121. - build-android14-6-1
  122. - build-android15-6-6
  123. - build-android16-6-12
  124. steps:
  125. - name: Download Misc Artifacts
  126. uses: actions/download-artifact@v7
  127. with:
  128. path: ./downloaded-artifacts
  129. pattern: '*-Normal-Rejects'
  130. merge-multiple: false
  131. - name: Process Reject Artifacts
  132. run: |
  133. mkdir -p aio-rejects
  134. # Iterate over Rejects artifacts in downloaded-artifacts
  135. for dir in ./downloaded-artifacts/*-Rejects; do
  136. # Ensure it is a directory
  137. [ -d "$dir" ] || continue
  138. dirname=$(basename "$dir")
  139. # Process each reject artifact
  140. # Get original name (remove -Rejects suffix)
  141. original_name=${dirname%-Rejects}
  142. mkdir -p "aio-rejects/$original_name"
  143. # Check for patch-rejects folder (legacy structure) or direct contents
  144. if [ -d "$dir/patch-rejects" ]; then
  145. # Legacy structure
  146. cp -r "$dir/patch-rejects/." "aio-rejects/$original_name/"
  147. else
  148. # Current structure
  149. cp -r "$dir/." "aio-rejects/$original_name/"
  150. fi
  151. done
  152. # Zip and upload if we found anything
  153. if [ "$(ls -A aio-rejects)" ]; then
  154. # Create a single zip of all rejects
  155. cd aio-rejects
  156. zip -r -q -9 ../AIO-REJ.zip .
  157. cd ..
  158. else
  159. echo "No rejects found to upload."
  160. fi
  161. - name: Rejects Summary
  162. run: |
  163. echo "Reject artifacts were collected locally only and are not uploaded." >> "$GITHUB_STEP_SUMMARY"
  164. - name: Upload AIO-REJ Artifact
  165. uses: actions/upload-artifact@v7
  166. with:
  167. name: AIO-REJ
  168. path: AIO-REJ.zip
  169. if-no-files-found: ignore
  170. release-preview:
  171. runs-on: ubuntu-latest
  172. if: ${{ github.event_name == 'workflow_dispatch' && inputs.test_release_notes == true }}
  173. permissions:
  174. contents: read
  175. env:
  176. GH_TOKEN: ${{ github.token }}
  177. RELEASE_NOTES: .github/config/RELEASE_NOTES.md
  178. COMMITS_JSON: .github/config/commits.json
  179. steps:
  180. - name: Checkout code
  181. uses: actions/checkout@v5
  182. - name: Extract KernelSU Version Info
  183. id: ksu_version
  184. env:
  185. COMMITS_JSON_PATH: ${{ env.COMMITS_JSON }}
  186. run: |
  187. set -euo pipefail
  188. # Extract KernelSU commit and branch from commits config
  189. KSUN_COMMIT=$(jq -er '.kernelsu.dev' "$COMMITS_JSON_PATH")
  190. KSUN_BRANCH="dev"
  191. # Clone KernelSU-Next on the specified branch
  192. echo "Cloning KernelSU-Next from branch: $KSUN_BRANCH"
  193. git clone --depth=1 --branch "$KSUN_BRANCH" https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
  194. cd /tmp/kernelsu-next
  195. # Checkout the specific commit
  196. echo "Checking out commit: $KSUN_COMMIT"
  197. git fetch --depth=50 origin "$KSUN_COMMIT"
  198. git checkout "$KSUN_COMMIT"
  199. # Extract version info
  200. COMMITS_COUNT=$(git rev-list --count HEAD)
  201. BASE_VERSION=30000
  202. KSU_VERSION=$(expr $COMMITS_COUNT "+" $BASE_VERSION)
  203. # Extract git tag
  204. KSU_GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "no-tag")
  205. MANAGER_RUN_ID=$(curl -fsSL "https://api.github.com/repos/KernelSU-Next/KernelSU-Next/actions/workflows/build-manager-ci.yml/runs?head_sha=${KSUN_COMMIT}" | jq -r '.workflow_runs[0].id // empty')
  206. if [[ -n "${MANAGER_RUN_ID:-}" ]]; then
  207. KSU_MANAGER="https://github.com/KernelSU-Next/KernelSU-Next/actions/runs/${MANAGER_RUN_ID}"
  208. else
  209. KSU_MANAGER="https://github.com/KernelSU-Next/KernelSU-Next/actions/workflows/build-manager-ci.yml"
  210. fi
  211. echo "Commits count: $COMMITS_COUNT"
  212. echo "KSU Version: $KSU_VERSION"
  213. echo "KSU Git Tag: $KSU_GIT_TAG"
  214. echo "KSU Manager: $KSU_MANAGER"
  215. # Export as environment for next step
  216. echo "KSUN_BRANCH=$KSUN_BRANCH" >> $GITHUB_ENV
  217. echo "KSUN_COMMIT=$KSUN_COMMIT" >> $GITHUB_ENV
  218. echo "KSU_COMMITS_COUNT=$COMMITS_COUNT" >> $GITHUB_ENV
  219. echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
  220. echo "KSU_GIT_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
  221. echo "KSU_MANAGER=$KSU_MANAGER" >> $GITHUB_ENV
  222. - name: Set release body
  223. run: |
  224. set -e
  225. RELEASE_NOTES_PATH="$RELEASE_NOTES"
  226. : > release_body.md
  227. python3 .github/scripts/render_release_body.py "$RELEASE_NOTES_PATH" > release_body.md
  228. - name: Publish release notes preview
  229. run: |
  230. {
  231. echo "## Release Notes Preview"
  232. echo
  233. cat release_body.md
  234. } >> "$GITHUB_STEP_SUMMARY"
  235. release:
  236. runs-on: ubuntu-latest
  237. if: ${{ github.event_name == 'workflow_dispatch' && !inputs.test_release_notes && (inputs.release_type == 'Pre-Release' || inputs.release_type == 'Release') }}
  238. permissions:
  239. contents: write
  240. needs:
  241. - build-android12-5-10
  242. - build-android13-5-10
  243. - build-android13-5-15
  244. - build-android14-5-15
  245. - build-android14-6-1
  246. - build-android15-6-6
  247. - build-android16-6-12
  248. env:
  249. GH_TOKEN: ${{ github.token }}
  250. RELEASE_NOTES: .github/config/RELEASE_NOTES.md
  251. COMMITS_JSON: .github/config/commits.json
  252. outputs:
  253. new_tag: ${{ steps.tag.outputs.new_tag }}
  254. steps:
  255. - name: Validate Selected Builds
  256. run: |
  257. set -euo pipefail
  258. failed=0
  259. current_type="${{ inputs.kernel_build_version }}"
  260. check_selected() {
  261. local target="$1"
  262. local job_name="$2"
  263. local result="$3"
  264. if [[ "$current_type" == "all" || "$current_type" == "$target" ]]; then
  265. if [[ "$result" != "success" ]]; then
  266. echo "Required job $job_name did not succeed (result: $result)"
  267. failed=1
  268. fi
  269. fi
  270. }
  271. check_selected "android12-5.10" "build-android12-5-10" "${{ needs.build-android12-5-10.result }}"
  272. check_selected "android13-5.10" "build-android13-5-10" "${{ needs.build-android13-5-10.result }}"
  273. check_selected "android13-5.15" "build-android13-5-15" "${{ needs.build-android13-5-15.result }}"
  274. check_selected "android14-5.15" "build-android14-5-15" "${{ needs.build-android14-5-15.result }}"
  275. check_selected "android14-6.1" "build-android14-6-1" "${{ needs.build-android14-6-1.result }}"
  276. check_selected "android15-6.6" "build-android15-6-6" "${{ needs.build-android15-6-6.result }}"
  277. check_selected "android16-6.12" "build-android16-6-12" "${{ needs.build-android16-6-12.result }}"
  278. if [[ "$failed" -ne 0 ]]; then
  279. exit 1
  280. fi
  281. - name: Free Disk Space
  282. if: true
  283. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  284. with:
  285. remove_android: true
  286. remove_dotnet: true
  287. remove_haskell: true
  288. remove_tool_cache: true
  289. remove_swap: true
  290. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  291. remove_packages_one_command: true
  292. remove_folders: "/usr/share/swift /usr/share/miniconda /usr/share/az* /usr/local/lib/node_modules /usr/local/share/chromium /usr/local/share/powershell /usr/local/julia /usr/local/aws-cli /usr/local/aws-sam-cli /usr/share/gradle"
  293. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  294. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  295. testing: false
  296. - name: Checkout code
  297. uses: actions/checkout@v5
  298. - name: Generate New Tag
  299. id: tag
  300. if: inputs.release_type != 'Action'
  301. run: |
  302. LATEST_TAG=$(gh api repos/${{ github.repository }}/tags --jq '.[0].name' 2>/dev/null || echo "v0.0.0")
  303. if [[ -z "$LATEST_TAG" || "$LATEST_TAG" == "null" ]]; then
  304. LATEST_TAG="v0.0.0"
  305. fi
  306. if [[ "$LATEST_TAG" =~ ^(.*)-r([0-9]+)$ ]]; then
  307. VERSION="${BASH_REMATCH[1]}"
  308. REV="${BASH_REMATCH[2]}"
  309. NEW_REV=$((REV + 1))
  310. NEW_TAG="${VERSION}-r${NEW_REV}"
  311. else
  312. NEW_TAG="${LATEST_TAG}-r1"
  313. fi
  314. echo "Latest tag: $LATEST_TAG"
  315. echo "New tag: $NEW_TAG"
  316. echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
  317. echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
  318. - name: Set Release Title
  319. id: release_meta
  320. run: |
  321. set -euo pipefail
  322. release_title="GKI Kernel Build ${NEW_TAG}"
  323. echo "release_title=$release_title" >> "$GITHUB_OUTPUT"
  324. - name: Extract KernelSU Version Info
  325. id: ksu_version
  326. env:
  327. COMMITS_JSON_PATH: ${{ env.COMMITS_JSON }}
  328. run: |
  329. set -euo pipefail
  330. # Extract KernelSU commit and branch from commits config
  331. KSUN_COMMIT=$(jq -er '.kernelsu.dev' "$COMMITS_JSON_PATH")
  332. KSUN_BRANCH="dev"
  333. # Clone KernelSU-Next on the specified branch
  334. echo "Cloning KernelSU-Next from branch: $KSUN_BRANCH"
  335. git clone --depth=1 --branch "$KSUN_BRANCH" https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
  336. cd /tmp/kernelsu-next
  337. # Checkout the specific commit
  338. echo "Checking out commit: $KSUN_COMMIT"
  339. git fetch --depth=50 origin "$KSUN_COMMIT"
  340. git checkout "$KSUN_COMMIT"
  341. # Extract version info
  342. COMMITS_COUNT=$(git rev-list --count HEAD)
  343. BASE_VERSION=30000
  344. KSU_VERSION=$(expr $COMMITS_COUNT "+" $BASE_VERSION)
  345. # Extract git tag
  346. KSU_GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "no-tag")
  347. MANAGER_RUN_ID=$(curl -fsSL "https://api.github.com/repos/KernelSU-Next/KernelSU-Next/actions/workflows/build-manager-ci.yml/runs?head_sha=${KSUN_COMMIT}" | jq -r '.workflow_runs[0].id // empty')
  348. if [[ -n "${MANAGER_RUN_ID:-}" ]]; then
  349. KSU_MANAGER="https://github.com/KernelSU-Next/KernelSU-Next/actions/runs/${MANAGER_RUN_ID}"
  350. else
  351. KSU_MANAGER="https://github.com/KernelSU-Next/KernelSU-Next/actions/workflows/build-manager-ci.yml"
  352. fi
  353. echo "Commits count: $COMMITS_COUNT"
  354. echo "KSU Version: $KSU_VERSION"
  355. echo "KSU Git Tag: $KSU_GIT_TAG"
  356. echo "KSU Manager: $KSU_MANAGER"
  357. # Export as environment for next step
  358. echo "KSUN_BRANCH=$KSUN_BRANCH" >> $GITHUB_ENV
  359. echo "KSUN_COMMIT=$KSUN_COMMIT" >> $GITHUB_ENV
  360. echo "KSU_COMMITS_COUNT=$COMMITS_COUNT" >> $GITHUB_ENV
  361. echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
  362. echo "KSU_GIT_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
  363. echo "KSU_MANAGER=$KSU_MANAGER" >> $GITHUB_ENV
  364. - name: Set release body
  365. run: |
  366. set -e
  367. RELEASE_NOTES_PATH="$RELEASE_NOTES"
  368. : > release_body.md
  369. python3 .github/scripts/render_release_body.py "$RELEASE_NOTES_PATH" > release_body.md
  370. - name: Publish release notes preview
  371. run: |
  372. {
  373. echo "## Release Notes Preview"
  374. echo
  375. cat release_body.md
  376. } >> "$GITHUB_STEP_SUMMARY"
  377. - name: Download AnyKernel3 Artifacts
  378. uses: actions/download-artifact@v7
  379. with:
  380. path: release-assets
  381. pattern: '*-AnyKernel3'
  382. merge-multiple: false
  383. - name: Zip AnyKernel3 for Release
  384. run: |
  385. set -e
  386. shopt -s nullglob
  387. for dir in release-assets/*-AnyKernel3; do
  388. zip_name="${dir}.zip"
  389. rm -f "$zip_name"
  390. cd "$dir"
  391. zip -r -q -9 "../$(basename "$zip_name")" .
  392. cd - >/dev/null
  393. done
  394. - name: Create Release
  395. uses: softprops/action-gh-release@v1
  396. with:
  397. tag_name: ${{ steps.tag.outputs.new_tag }}
  398. name: ${{ steps.release_meta.outputs.release_title }}
  399. body_path: release_body.md
  400. draft: false
  401. prerelease: ${{ inputs.release_type == 'Pre-Release' }}
  402. files: |
  403. release-assets/**/*.zip
  404. release-assets/**/*-boot*.img