name: Build Kernels permissions: contents: write actions: write on: workflow_dispatch: inputs: release_type: description: "Release Type" type: choice options: - Action - Pre-Release - Release default: Action kernel_build_version: description: "Kernel Version" type: choice options: - All - android12-5.10 - android13-5.10 - android13-5.15 - android14-5.15 - android14-6.1 - android15-6.6 - android16-6.12 default: All feature_set: description: "Feature Set" type: choice options: - KSUN+SUSFS+BBG+NET+DS - KSUN+SUSFS+BBG - KSUN+SUSFS+NET - KSUN+SUSFS+DS - KSUN+SUSFS - KSUN+BBG - KSUN+NET - KSUN+DS - KSUN - NONE - FULL default: FULL ksu_branch: description: "KernelSU branch or commit (empty = latest dev-susfs branch tip)" type: string required: false default: "" susfs_commit_android12-5-10: description: "SUSFS commit for android12-5.10 (empty = latest branch tip)" type: string required: false default: "" susfs_commit_android13-5-10: description: "SUSFS commit for android13-5.10 (empty = latest branch tip)" type: string required: false default: "" susfs_commit_android13-5-15: description: "SUSFS commit for android13-5.15 (empty = latest branch tip)" type: string required: false default: "" susfs_commit_android14-5-15: description: "SUSFS commit for android14-5.15 (empty = latest branch tip)" type: string required: false default: "" susfs_commit_android14-6-1: description: "SUSFS commit for android14-6.1 (empty = latest branch tip)" type: string required: false default: "" susfs_commit_android15-6-6: description: "SUSFS commit for android15-6.6 (empty = latest branch tip)" type: string required: false default: "" susfs_commit_android16-6-12: description: "SUSFS commit for android16-6.12 (empty = latest branch tip)" type: string required: false default: "" jobs: prepare-ccache: name: Prepare ccache binary (download once) runs-on: ubuntu-latest steps: - name: Download custom ccache once if: false run: | set -uo pipefail echo "::group::Download ccache" url="https://raw.githubusercontent.com/WildKernels/kernel_patches/refs/heads/main/ccache/ccache-x86-64" ok=0 for attempt in 1 2 3 4 5 6; do if curl -LfsS --connect-timeout 30 --max-time 120 -H "User-Agent: Mozilla/5.0" "$url" -o ccache && [ -s ccache ]; then ok=1; break fi echo "attempt $attempt failed (GitHub raw 504/throttle); backing off..." sleep $(( attempt * 5 + RANDOM % 6 )) done if [ "$ok" = 1 ]; then echo "โœ… downloaded ccache once for all matrix jobs" else echo "::warning::custom ccache download failed; matrix jobs will fall back to the apt ccache" rm -f ccache fi echo "::endgroup::" - name: Upload ccache artifact if: false uses: actions/upload-artifact@v7 with: name: ccache-binary path: ccache retention-days: 1 if-no-files-found: warn build-android12-5-10: needs: prepare-ccache if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android12-5.10') }} uses: ./.github/workflows/prepare.yml with: config_file: .github/config/android12-5.10.json feature_set: ${{ inputs.feature_set || 'FULL' }} ksu_branch: ${{ inputs.ksu_branch }} susfs_commit: ${{ inputs.susfs_commit_android12-5-10 }} secrets: inherit build-android13-5-10: needs: prepare-ccache if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android13-5.10') }} uses: ./.github/workflows/prepare.yml with: config_file: .github/config/android13-5.10.json feature_set: ${{ inputs.feature_set || 'FULL' }} ksu_branch: ${{ inputs.ksu_branch }} susfs_commit: ${{ inputs.susfs_commit_android13-5-10 }} secrets: inherit build-android13-5-15: needs: prepare-ccache if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android13-5.15') }} uses: ./.github/workflows/prepare.yml with: config_file: .github/config/android13-5.15.json feature_set: ${{ inputs.feature_set || 'FULL' }} ksu_branch: ${{ inputs.ksu_branch }} susfs_commit: ${{ inputs.susfs_commit_android13-5-15 }} secrets: inherit build-android14-5-15: needs: prepare-ccache if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android14-5.15') }} uses: ./.github/workflows/prepare.yml with: config_file: .github/config/android14-5.15.json feature_set: ${{ inputs.feature_set || 'FULL' }} ksu_branch: ${{ inputs.ksu_branch }} susfs_commit: ${{ inputs.susfs_commit_android14-5-15 }} secrets: inherit build-android14-6-1: needs: prepare-ccache if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android14-6.1') }} uses: ./.github/workflows/prepare.yml with: config_file: .github/config/android14-6.1.json feature_set: ${{ inputs.feature_set || 'FULL' }} ksu_branch: ${{ inputs.ksu_branch }} susfs_commit: ${{ inputs.susfs_commit_android14-6-1 }} secrets: inherit build-android15-6-6: needs: prepare-ccache if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android15-6.6') }} uses: ./.github/workflows/prepare.yml with: config_file: .github/config/android15-6.6.json feature_set: ${{ inputs.feature_set || 'FULL' }} ksu_branch: ${{ inputs.ksu_branch }} susfs_commit: ${{ inputs.susfs_commit_android15-6-6 }} secrets: inherit build-android16-6-12: needs: prepare-ccache if: ${{ !inputs.test_release_notes && (inputs.kernel_build_version == 'All' || inputs.kernel_build_version == 'android16-6.12') }} uses: ./.github/workflows/prepare.yml with: config_file: .github/config/android16-6.12.json feature_set: ${{ inputs.feature_set || 'FULL' }} ksu_branch: ${{ inputs.ksu_branch }} susfs_commit: ${{ inputs.susfs_commit_android16-6-12 }} secrets: inherit rej: if: ${{ !inputs.test_release_notes && always() }} runs-on: ubuntu-latest permissions: actions: read contents: read needs: - build-android12-5-10 - build-android13-5-10 - build-android13-5-15 - build-android14-5-15 - build-android14-6-1 - build-android15-6-6 - build-android16-6-12 steps: - name: Download Misc Artifacts uses: actions/download-artifact@v7 with: path: ./downloaded-artifacts pattern: '*-Rejects' merge-multiple: false - name: Process Reject Artifacts run: | mkdir -p aio-rejects # Iterate over Rejects artifacts in downloaded-artifacts for dir in ./downloaded-artifacts/*-Rejects; do [ -d "$dir" ] || continue dirname=$(basename "$dir") original_name=${dirname%-Rejects} source_dir="$dir" if [ -d "$dir/patch-rejects" ]; then source_dir="$dir/patch-rejects" fi mapfile -t rej_files < <(find "$source_dir" -type f -name '*.rej' | sort) filtered_rej_files=() for rej_file in "${rej_files[@]}"; do rel_rej="${rej_file#${source_dir}/}" rel_name="$(basename "$rel_rej")" if [ "$rel_rej" = "common/mm/rmap.c.rej" ] || [ "$rel_name" = "i2c-nomadik.c.rej" ]; then echo "Skipping $rel_rej because it is an ignored reject file" continue fi filtered_rej_files+=("$rej_file") done if [ "${#filtered_rej_files[@]}" -eq 0 ]; then echo "Skipping $dirname because it only contains ignored reject files" continue fi mkdir -p "aio-rejects/$original_name" if [ -d "$dir/patch-rejects" ]; then cp -r "$dir/patch-rejects/." "aio-rejects/$original_name/" else cp -r "$dir/." "aio-rejects/$original_name/" fi find "aio-rejects/$original_name" -type f -name 'i2c-nomadik.c.rej' -delete done if [ "$(ls -A aio-rejects)" ]; then cd aio-rejects zip -r -q -9 ../AIO-REJ.zip . cd .. else echo "No rejects found to upload." fi - name: Rejects Summary run: | echo "Reject artifacts were collected locally only and are not uploaded." >> "$GITHUB_STEP_SUMMARY" - name: Upload AIO-REJ Artifact uses: actions/upload-artifact@v7 with: name: AIO-REJ path: AIO-REJ.zip if-no-files-found: ignore summary: if: ${{ !inputs.test_release_notes && always() }} runs-on: ubuntu-latest permissions: actions: write contents: read needs: - build-android12-5-10 - build-android13-5-10 - build-android13-5-15 - build-android14-5-15 - build-android14-6-1 - build-android15-6-6 - build-android16-6-12 steps: - name: Download All Build Summaries uses: actions/download-artifact@v7 with: path: ./summaries pattern: '*-Summary' merge-multiple: true - name: ๐Ÿ“‹ Workflow Build Summary run: | { echo "# ๐Ÿ“‹ Build Summary โ€” $(date -u '+%Y-%m-%d %H:%M UTC')" echo echo "**Feature Set:** ${{ inputs.feature_set }}" echo "**KSU Branch:** ${{ inputs.ksu_branch || 'latest dev' }}" echo # Count successes and failures SUCCESS_COUNT=0 FAIL_COUNT=0 # Sort summaries so they appear in a consistent order for f in ./summaries/*.md; do [ -f "$f" ] || continue if grep -q "โœ… Success" "$f"; then SUCCESS_COUNT=$((SUCCESS_COUNT + 1)) else FAIL_COUNT=$((FAIL_COUNT + 1)) fi done TOTAL=$((SUCCESS_COUNT + FAIL_COUNT)) echo "**Results:** ${SUCCESS_COUNT}/${TOTAL} succeeded" if [ "$FAIL_COUNT" -gt 0 ]; then echo " - โŒ ${FAIL_COUNT} failed" fi echo echo "---" echo # Output each summary for f in ./summaries/*.md; do [ -f "$f" ] || continue cat "$f" echo echo "---" echo done echo echo "> **SUSFS Commits:**" echo "> - android12-5.10: ${{ inputs.susfs_commit_android12-5-10 || 'latest' }}" echo "> - android13-5.10: ${{ inputs.susfs_commit_android13-5-10 || 'latest' }}" echo "> - android13-5.15: ${{ inputs.susfs_commit_android13-5-15 || 'latest' }}" echo "> - android14-5.15: ${{ inputs.susfs_commit_android14-5-15 || 'latest' }}" echo "> - android14-6.1: ${{ inputs.susfs_commit_android14-6-1 || 'latest' }}" echo "> - android15-6.6: ${{ inputs.susfs_commit_android15-6-6 || 'latest' }}" echo "> - android16-6.12: ${{ inputs.susfs_commit_android16-6-12 || 'latest' }}" } >> "$GITHUB_STEP_SUMMARY" - name: ๐Ÿงน Cleanup Summary Files if: ${{ always() }} run: rm -rf ./summaries - name: ๐Ÿงน Delete Summary Artifacts if: ${{ always() }} env: GH_TOKEN: ${{ github.token }} run: | # Delete all *-Summary artifacts from this run since they're now consolidated RUN_ID="${{ github.run_id }}" ARTIFACTS=$(gh api "repos/${{ github.repository }}/actions/runs/${RUN_ID}/artifacts" --jq '.artifacts[] | select(.name | endswith("-Summary")) | .id') for id in $ARTIFACTS; do echo "Deleting summary artifact id=$id" gh api -X DELETE "repos/${{ github.repository }}/actions/artifacts/${id}" || true done release: runs-on: ubuntu-latest if: ${{ github.event_name == 'workflow_dispatch' && !inputs.test_release_notes && (inputs.release_type == 'Pre-Release' || inputs.release_type == 'Release') }} permissions: contents: write needs: - build-android12-5-10 - build-android13-5-10 - build-android13-5-15 - build-android14-5-15 - build-android14-6-1 - build-android15-6-6 - build-android16-6-12 env: GH_TOKEN: ${{ github.token }} RELEASE_NOTES: .github/config/RELEASE_NOTES.md outputs: new_tag: ${{ steps.tag.outputs.new_tag }} steps: - name: Validate Selected Builds run: | set -euo pipefail failed=0 current_type="${{ inputs.kernel_build_version }}" check_selected() { local target="$1" local job_name="$2" local result="$3" if [[ "$current_type" == "all" || "$current_type" == "$target" ]]; then if [[ "$result" != "success" ]]; then echo "Required job $job_name did not succeed (result: $result)" failed=1 fi fi } check_selected "android12-5.10" "build-android12-5-10" "${{ needs.build-android12-5-10.result }}" check_selected "android13-5.10" "build-android13-5-10" "${{ needs.build-android13-5-10.result }}" check_selected "android13-5.15" "build-android13-5-15" "${{ needs.build-android13-5-15.result }}" check_selected "android14-5.15" "build-android14-5-15" "${{ needs.build-android14-5-15.result }}" check_selected "android14-6.1" "build-android14-6-1" "${{ needs.build-android14-6-1.result }}" check_selected "android15-6.6" "build-android15-6-6" "${{ needs.build-android15-6-6.result }}" check_selected "android16-6.12" "build-android16-6-12" "${{ needs.build-android16-6-12.result }}" if [[ "$failed" -ne 0 ]]; then exit 1 fi - name: Free Disk Space if: true uses: endersonmenezes/free-disk-space@v3 # Use @main for latest, @v3 for stable with: remove_android: true remove_dotnet: true remove_haskell: true remove_tool_cache: true remove_swap: true remove_packages: "azure-cli google-cloud-cli microsoft-edge-stable google-chrome-stable firefox postgresql* temurin-* *llvm* mysql* dotnet-sdk-*" remove_packages_one_command: true 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" rm_cmd: "rmz" # Use 'rmz' for faster deletion (default: 'rm') rmz_version: "3.1.1" # Required when rm_cmd is 'rmz' testing: false - name: Checkout code uses: actions/checkout@v7 - name: Generate New Tag id: tag if: inputs.release_type != 'Action' run: | 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) LATEST_REV=0 for TAG in "${RELEASE_TAGS[@]}"; do REV="${TAG#r}" if [[ "$REV" =~ ^[0-9]+$ && "$REV" -gt "$LATEST_REV" ]]; then LATEST_REV="$REV" fi done if [[ "$LATEST_REV" -gt 0 ]]; then NEW_TAG="r$((LATEST_REV + 1))" else NEW_TAG="r1" fi if [[ ${#RELEASE_TAGS[@]} -gt 0 ]]; then echo "Latest r-tag: r${LATEST_REV}" else echo "No existing r-tags found; starting at r1" fi echo "New tag: $NEW_TAG" echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT - name: Set Release Title id: release_meta run: | set -euo pipefail # Format release title: convert rN -> Release N if [[ "${NEW_TAG}" =~ ^r([0-9]+)$ ]]; then REV_NUM="${BASH_REMATCH[1]}" release_title="Release ${REV_NUM}" else release_title="Release ${NEW_TAG}" fi echo "release_title=$release_title" >> "$GITHUB_OUTPUT" - name: Extract KernelSU Version Info id: ksu_version run: | set -euo pipefail KSU_REPO="https://github.com/pershoot/KernelSU-Next.git" KSU_INPUT="${{ inputs.ksu_branch }}" if [ -z "$KSU_INPUT" ]; then KSU_INPUT="dev-susfs" fi # Try as branch first, fall back to commit if git ls-remote --heads "$KSU_REPO" "$KSU_INPUT" | grep -q .; then echo "Cloning KernelSU-Next from branch: $KSU_INPUT" git clone --branch "$KSU_INPUT" "$KSU_REPO" /tmp/kernelsu-next cd /tmp/kernelsu-next KSUN_COMMIT=$(git rev-parse HEAD) else echo "Cloning KernelSU-Next from dev-susfs branch, then checking out commit: $KSU_INPUT" git clone --branch dev-susfs "$KSU_REPO" /tmp/kernelsu-next cd /tmp/kernelsu-next git fetch --depth=50 origin "$KSU_INPUT" git checkout "$KSU_INPUT" KSUN_COMMIT="$KSU_INPUT" fi # Extract version info COMMITS_COUNT=$(git rev-list --count HEAD) BASE_VERSION=30000 KSU_VERSION=$(expr $COMMITS_COUNT "+" $BASE_VERSION) # Extract git tag KSU_GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "no-tag") MANAGER_RUN_ID=$(curl -fsSL "https://api.github.com/repos/pershoot/KernelSU-Next/actions/workflows/build-manager-ci.yml/runs?head_sha=${KSUN_COMMIT}" | jq -r '.workflow_runs[0].id // empty') if [[ -n "${MANAGER_RUN_ID:-}" ]]; then KSU_MANAGER="https://github.com/pershoot/KernelSU-Next/actions/runs/${MANAGER_RUN_ID}" else KSU_MANAGER="https://github.com/pershoot/KernelSU-Next/actions/workflows/build-manager-ci.yml" fi echo "Commits count: $COMMITS_COUNT" echo "KSU Version: $KSU_VERSION" echo "KSU Git Tag: $KSU_GIT_TAG" echo "KSU Manager: $KSU_MANAGER" # Export as environment for next step echo "KSUN_BRANCH=$KSU_INPUT" >> $GITHUB_ENV echo "KSUN_COMMIT=$KSUN_COMMIT" >> $GITHUB_ENV echo "KSU_COMMITS_COUNT=$COMMITS_COUNT" >> $GITHUB_ENV echo "KSU_VERSION=$KSU_VERSION" >> $GITHUB_ENV echo "KSU_GIT_TAG=$KSU_GIT_TAG" >> $GITHUB_ENV echo "KSU_MANAGER=$KSU_MANAGER" >> $GITHUB_ENV - name: Set release body run: | set -e RELEASE_NOTES_PATH="$RELEASE_NOTES" : > release_body.md python3 .github/scripts/render_release_body.py "$RELEASE_NOTES_PATH" > release_body.md - name: Publish release notes preview run: | { echo "## Release Notes Preview" echo cat release_body.md } >> "$GITHUB_STEP_SUMMARY" - name: Download AnyKernel3 Artifacts uses: actions/download-artifact@v7 with: path: release-assets pattern: '*-AnyKernel3' merge-multiple: false - name: Zip AnyKernel3 for Release run: | set -e shopt -s nullglob for dir in release-assets/*-AnyKernel3; do zip_name="${dir}.zip" rm -f "$zip_name" cd "$dir" zip -r -q -9 "../$(basename "$zip_name")" . cd - >/dev/null done - name: Create Release uses: softprops/action-gh-release@v1 with: tag_name: ${{ steps.tag.outputs.new_tag }} name: ${{ steps.release_meta.outputs.release_title }} body_path: release_body.md draft: false prerelease: ${{ inputs.release_type == 'Pre-Release' }} files: | release-assets/**/*.zip release-assets/**/*-boot*.img