main.yml 17 KB

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