main.yml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  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. source_dir="$dir"
  151. if [ -d "$dir/patch-rejects" ]; then
  152. source_dir="$dir/patch-rejects"
  153. fi
  154. mapfile -t rej_files < <(find "$source_dir" -type f -name '*.rej' | sort)
  155. if [ "${#rej_files[@]}" -eq 1 ]; then
  156. rel_rej="${rej_files[0]#${source_dir}/}"
  157. if [ "$rel_rej" = "common/mm/rmap.c.rej" ]; then
  158. echo "Skipping $dirname because it only contains common/mm/rmap.c.rej"
  159. continue
  160. fi
  161. fi
  162. mkdir -p "aio-rejects/$original_name"
  163. if [ -d "$dir/patch-rejects" ]; then
  164. cp -r "$dir/patch-rejects/." "aio-rejects/$original_name/"
  165. else
  166. cp -r "$dir/." "aio-rejects/$original_name/"
  167. fi
  168. done
  169. if [ "$(ls -A aio-rejects)" ]; then
  170. cd aio-rejects
  171. zip -r -q -9 ../AIO-REJ.zip .
  172. cd ..
  173. else
  174. echo "No rejects found to upload."
  175. fi
  176. - name: Rejects Summary
  177. run: |
  178. echo "Reject artifacts were collected locally only and are not uploaded." >> "$GITHUB_STEP_SUMMARY"
  179. - name: Upload AIO-REJ Artifact
  180. uses: actions/upload-artifact@v7
  181. with:
  182. name: AIO-REJ
  183. path: AIO-REJ.zip
  184. if-no-files-found: ignore
  185. release-preview:
  186. runs-on: ubuntu-latest
  187. if: ${{ github.event_name == 'workflow_dispatch' && inputs.test_release_notes == true }}
  188. permissions:
  189. contents: read
  190. env:
  191. GH_TOKEN: ${{ github.token }}
  192. RELEASE_NOTES: .github/config/RELEASE_NOTES.md
  193. COMMITS_JSON: .github/config/commits.json
  194. steps:
  195. - name: Checkout code
  196. uses: actions/checkout@v5
  197. - name: Extract KernelSU Version Info
  198. id: ksu_version
  199. env:
  200. COMMITS_JSON_PATH: ${{ env.COMMITS_JSON }}
  201. run: |
  202. set -euo pipefail
  203. KSUN_BRANCH="dev"
  204. if [ "${{ inputs.use_latest_commits }}" = "true" ]; then
  205. echo "Cloning KernelSU-Next from full branch tip: $KSUN_BRANCH"
  206. git clone --branch "$KSUN_BRANCH" https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
  207. else
  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. fi
  211. cd /tmp/kernelsu-next
  212. if [ "${{ inputs.use_latest_commits }}" = "true" ]; then
  213. KSUN_COMMIT=$(git rev-parse HEAD)
  214. else
  215. KSUN_COMMIT=$(jq -er '.kernelsu.dev' "$COMMITS_JSON_PATH")
  216. echo "Checking out commit: $KSUN_COMMIT"
  217. git fetch --depth=50 origin "$KSUN_COMMIT"
  218. git checkout "$KSUN_COMMIT"
  219. fi
  220. COMMITS_COUNT=$(git rev-list --count HEAD)
  221. BASE_VERSION=30000
  222. KSU_VERSION=$(expr $COMMITS_COUNT "+" $BASE_VERSION)
  223. KSU_GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "no-tag")
  224. 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')
  225. if [[ -n "${MANAGER_RUN_ID:-}" ]]; then
  226. KSU_MANAGER="https://github.com/KernelSU-Next/KernelSU-Next/actions/runs/${MANAGER_RUN_ID}"
  227. else
  228. KSU_MANAGER="https://github.com/KernelSU-Next/KernelSU-Next/actions/workflows/build-manager-ci.yml"
  229. fi
  230. echo "Commits count: $COMMITS_COUNT"
  231. echo "KSU Version: $KSU_VERSION"
  232. echo "KSU Git Tag: $KSU_GIT_TAG"
  233. echo "KSU Manager: $KSU_MANAGER"
  234. echo "KSUN_BRANCH=$KSUN_BRANCH" >> $GITHUB_ENV
  235. echo "KSUN_COMMIT=$KSUN_COMMIT" >> $GITHUB_ENV
  236. echo "KSU_COMMITS_COUNT=$COMMITS_COUNT" >> $GITHUB_ENV
  237. echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
  238. echo "KSU_GIT_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
  239. echo "KSU_MANAGER=$KSU_MANAGER" >> $GITHUB_ENV
  240. - name: Set release body
  241. run: |
  242. set -e
  243. RELEASE_NOTES_PATH="$RELEASE_NOTES"
  244. : > release_body.md
  245. python3 .github/scripts/render_release_body.py "$RELEASE_NOTES_PATH" > release_body.md
  246. - name: Publish release notes preview
  247. run: |
  248. {
  249. echo "## Release Notes Preview"
  250. echo
  251. cat release_body.md
  252. } >> "$GITHUB_STEP_SUMMARY"
  253. release:
  254. runs-on: ubuntu-latest
  255. if: ${{ github.event_name == 'workflow_dispatch' && !inputs.test_release_notes && (inputs.release_type == 'Pre-Release' || inputs.release_type == 'Release') }}
  256. permissions:
  257. contents: write
  258. needs:
  259. - build-android12-5-10
  260. - build-android13-5-10
  261. - build-android13-5-15
  262. - build-android14-5-15
  263. - build-android14-6-1
  264. - build-android15-6-6
  265. - build-android16-6-12
  266. env:
  267. GH_TOKEN: ${{ github.token }}
  268. RELEASE_NOTES: .github/config/RELEASE_NOTES.md
  269. COMMITS_JSON: .github/config/commits.json
  270. outputs:
  271. new_tag: ${{ steps.tag.outputs.new_tag }}
  272. steps:
  273. - name: Validate Selected Builds
  274. run: |
  275. set -euo pipefail
  276. failed=0
  277. current_type="${{ inputs.kernel_build_version }}"
  278. check_selected() {
  279. local target="$1"
  280. local job_name="$2"
  281. local result="$3"
  282. if [[ "$current_type" == "all" || "$current_type" == "$target" ]]; then
  283. if [[ "$result" != "success" ]]; then
  284. echo "Required job $job_name did not succeed (result: $result)"
  285. failed=1
  286. fi
  287. fi
  288. }
  289. check_selected "android12-5.10" "build-android12-5-10" "${{ needs.build-android12-5-10.result }}"
  290. check_selected "android13-5.10" "build-android13-5-10" "${{ needs.build-android13-5-10.result }}"
  291. check_selected "android13-5.15" "build-android13-5-15" "${{ needs.build-android13-5-15.result }}"
  292. check_selected "android14-5.15" "build-android14-5-15" "${{ needs.build-android14-5-15.result }}"
  293. check_selected "android14-6.1" "build-android14-6-1" "${{ needs.build-android14-6-1.result }}"
  294. check_selected "android15-6.6" "build-android15-6-6" "${{ needs.build-android15-6-6.result }}"
  295. check_selected "android16-6.12" "build-android16-6-12" "${{ needs.build-android16-6-12.result }}"
  296. if [[ "$failed" -ne 0 ]]; then
  297. exit 1
  298. fi
  299. - name: Free Disk Space
  300. if: true
  301. uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable
  302. with:
  303. remove_android: true
  304. remove_dotnet: true
  305. remove_haskell: true
  306. remove_tool_cache: true
  307. remove_swap: true
  308. remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*"
  309. remove_packages_one_command: true
  310. 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"
  311. rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm')
  312. rmz_version: "3.1.1" # Required when rm_cmd is 'rmz'
  313. testing: false
  314. - name: Checkout code
  315. uses: actions/checkout@v5
  316. - name: Generate New Tag
  317. id: tag
  318. if: inputs.release_type != 'Action'
  319. run: |
  320. 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)
  321. LATEST_REV=0
  322. for TAG in "${RELEASE_TAGS[@]}"; do
  323. REV="${TAG#r}"
  324. if [[ "$REV" =~ ^[0-9]+$ && "$REV" -gt "$LATEST_REV" ]]; then
  325. LATEST_REV="$REV"
  326. fi
  327. done
  328. if [[ "$LATEST_REV" -gt 0 ]]; then
  329. NEW_TAG="r$((LATEST_REV + 1))"
  330. else
  331. NEW_TAG="r1"
  332. fi
  333. if [[ ${#RELEASE_TAGS[@]} -gt 0 ]]; then
  334. echo "Latest r-tag: r${LATEST_REV}"
  335. else
  336. echo "No existing r-tags found; starting at r1"
  337. fi
  338. echo "New tag: $NEW_TAG"
  339. echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV
  340. echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
  341. - name: Set Release Title
  342. id: release_meta
  343. run: |
  344. set -euo pipefail
  345. # Format release title: convert rN -> Release N
  346. if [[ "${NEW_TAG}" =~ ^r([0-9]+)$ ]]; then
  347. REV_NUM="${BASH_REMATCH[1]}"
  348. release_title="Wild Kernels for GKI2 Devices 5.10+ Release ${REV_NUM}"
  349. else
  350. release_title="Wild Kernels for GKI2 Devices 5.10+ Release ${NEW_TAG}"
  351. fi
  352. echo "release_title=$release_title" >> "$GITHUB_OUTPUT"
  353. - name: Extract KernelSU Version Info
  354. id: ksu_version
  355. env:
  356. COMMITS_JSON_PATH: ${{ env.COMMITS_JSON }}
  357. run: |
  358. set -euo pipefail
  359. KSUN_BRANCH="dev"
  360. if [ "${{ inputs.use_latest_commits }}" = "true" ]; then
  361. echo "Cloning KernelSU-Next from full branch tip: $KSUN_BRANCH"
  362. git clone --branch "$KSUN_BRANCH" https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
  363. else
  364. echo "Cloning KernelSU-Next from branch: $KSUN_BRANCH"
  365. git clone --depth=1 --branch "$KSUN_BRANCH" https://github.com/KernelSU-Next/KernelSU-Next.git /tmp/kernelsu-next
  366. fi
  367. cd /tmp/kernelsu-next
  368. if [ "${{ inputs.use_latest_commits }}" = "true" ]; then
  369. KSUN_COMMIT=$(git rev-parse HEAD)
  370. else
  371. # Extract KernelSU commit and branch from commits config
  372. KSUN_COMMIT=$(jq -er '.kernelsu.dev' "$COMMITS_JSON_PATH")
  373. echo "Checking out commit: $KSUN_COMMIT"
  374. git fetch --depth=50 origin "$KSUN_COMMIT"
  375. git checkout "$KSUN_COMMIT"
  376. fi
  377. # Extract version info
  378. COMMITS_COUNT=$(git rev-list --count HEAD)
  379. BASE_VERSION=30000
  380. KSU_VERSION=$(expr $COMMITS_COUNT "+" $BASE_VERSION)
  381. # Extract git tag
  382. KSU_GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "no-tag")
  383. 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')
  384. if [[ -n "${MANAGER_RUN_ID:-}" ]]; then
  385. KSU_MANAGER="https://github.com/KernelSU-Next/KernelSU-Next/actions/runs/${MANAGER_RUN_ID}"
  386. else
  387. KSU_MANAGER="https://github.com/KernelSU-Next/KernelSU-Next/actions/workflows/build-manager-ci.yml"
  388. fi
  389. echo "Commits count: $COMMITS_COUNT"
  390. echo "KSU Version: $KSU_VERSION"
  391. echo "KSU Git Tag: $KSU_GIT_TAG"
  392. echo "KSU Manager: $KSU_MANAGER"
  393. # Export as environment for next step
  394. echo "KSUN_BRANCH=$KSUN_BRANCH" >> $GITHUB_ENV
  395. echo "KSUN_COMMIT=$KSUN_COMMIT" >> $GITHUB_ENV
  396. echo "KSU_COMMITS_COUNT=$COMMITS_COUNT" >> $GITHUB_ENV
  397. echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV
  398. echo "KSU_GIT_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV
  399. echo "KSU_MANAGER=$KSU_MANAGER" >> $GITHUB_ENV
  400. - name: Set release body
  401. run: |
  402. set -e
  403. RELEASE_NOTES_PATH="$RELEASE_NOTES"
  404. : > release_body.md
  405. python3 .github/scripts/render_release_body.py "$RELEASE_NOTES_PATH" > release_body.md
  406. - name: Publish release notes preview
  407. run: |
  408. {
  409. echo "## Release Notes Preview"
  410. echo
  411. cat release_body.md
  412. } >> "$GITHUB_STEP_SUMMARY"
  413. - name: Download AnyKernel3 Artifacts
  414. uses: actions/download-artifact@v7
  415. with:
  416. path: release-assets
  417. pattern: '*-AnyKernel3'
  418. merge-multiple: false
  419. - name: Zip AnyKernel3 for Release
  420. run: |
  421. set -e
  422. shopt -s nullglob
  423. for dir in release-assets/*-AnyKernel3; do
  424. zip_name="${dir}.zip"
  425. rm -f "$zip_name"
  426. cd "$dir"
  427. zip -r -q -9 "../$(basename "$zip_name")" .
  428. cd - >/dev/null
  429. done
  430. - name: Create Release
  431. uses: softprops/action-gh-release@v1
  432. with:
  433. tag_name: ${{ steps.tag.outputs.new_tag }}
  434. name: ${{ steps.release_meta.outputs.release_title }}
  435. body_path: release_body.md
  436. draft: false
  437. prerelease: ${{ inputs.release_type == 'Pre-Release' }}
  438. files: |
  439. release-assets/**/*.zip
  440. release-assets/**/*-boot*.img