main.yml 17 KB

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