main.yml 18 KB

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