main.yml 18 KB

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