main.yml 16 KB

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