ci: improve kernel version parsing in build workflow #936
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Kernels | |
| permissions: | |
| contents: write | |
| actions: write | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_type: | |
| description: "Release Type" | |
| type: choice | |
| options: [ Actions, Pre-Release, Release ] | |
| default: Actions | |
| kernel_build_version: | |
| description: "Kernel Version to Build" | |
| type: choice | |
| options: | |
| - all | |
| - a12-5-10 | |
| - a13-5-10 | |
| - a13-5-15 | |
| - a14-5-15 | |
| - a14-6-1 | |
| - a15-6-6 | |
| - a16-6-12 | |
| - lts | |
| - custom | |
| - testing | |
| - bypass | |
| default: custom | |
| feature_set: | |
| description: "Feature Set" | |
| type: choice | |
| options: | |
| - WKSU+SUSFS+BBG | |
| - WKSU+BBG | |
| - WKSU | |
| - BBG | |
| - None | |
| default: WKSU+SUSFS+BBG | |
| ksu_commit: | |
| description: "KSU Commit (optional)" | |
| type: string | |
| default: "" | |
| required: false | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| fetch-latest-commits: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| ksu_commit: ${{ steps.fetch.outputs.ksu_commit }} | |
| anykernel_commit: ${{ steps.fetch.outputs.anykernel_commit }} | |
| patches_commit: ${{ steps.fetch.outputs.patches_commit }} | |
| susfs_commit: ${{ steps.fetch.outputs.susfs_commit }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Fetch Commits | |
| id: fetch | |
| uses: ./.github/actions/fetch-commits | |
| with: | |
| ksu_commit: ${{ inputs.ksu_commit }} | |
| build-a12-5-10: | |
| if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a12-5-10' }} | |
| needs: fetch-latest-commits | |
| uses: ./.github/workflows/prepare.yml | |
| with: | |
| config_file: .github/kernel-config/a12-5.10.json | |
| ksu_commit: ${{ inputs.ksu_commit || needs.fetch-latest-commits.outputs.ksu_commit }} | |
| anykernel_commit: ${{ needs.fetch-latest-commits.outputs.anykernel_commit }} | |
| patches_commit: ${{ needs.fetch-latest-commits.outputs.patches_commit }} | |
| susfs_commit: ${{ needs.fetch-latest-commits.outputs.susfs_commit }} | |
| feature_set: ${{ inputs.feature_set || 'WKSU+SUSFS+BBG' }} | |
| secrets: inherit | |
| build-a13-5-10: | |
| if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a13-5-10' }} | |
| needs: fetch-latest-commits | |
| uses: ./.github/workflows/prepare.yml | |
| with: | |
| config_file: .github/kernel-config/a13-5.10.json | |
| ksu_commit: ${{ inputs.ksu_commit || needs.fetch-latest-commits.outputs.ksu_commit }} | |
| anykernel_commit: ${{ needs.fetch-latest-commits.outputs.anykernel_commit }} | |
| patches_commit: ${{ needs.fetch-latest-commits.outputs.patches_commit }} | |
| susfs_commit: ${{ needs.fetch-latest-commits.outputs.susfs_commit }} | |
| feature_set: ${{ inputs.feature_set || 'WKSU+SUSFS+BBG' }} | |
| secrets: inherit | |
| build-a13-5-15: | |
| if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a13-5-15' }} | |
| needs: fetch-latest-commits | |
| uses: ./.github/workflows/prepare.yml | |
| with: | |
| config_file: .github/kernel-config/a13-5.15.json | |
| ksu_commit: ${{ inputs.ksu_commit || needs.fetch-latest-commits.outputs.ksu_commit }} | |
| anykernel_commit: ${{ needs.fetch-latest-commits.outputs.anykernel_commit }} | |
| patches_commit: ${{ needs.fetch-latest-commits.outputs.patches_commit }} | |
| susfs_commit: ${{ needs.fetch-latest-commits.outputs.susfs_commit }} | |
| feature_set: ${{ inputs.feature_set || 'WKSU+SUSFS+BBG' }} | |
| secrets: inherit | |
| build-a14-5-15: | |
| if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a14-5-15' }} | |
| needs: fetch-latest-commits | |
| uses: ./.github/workflows/prepare.yml | |
| with: | |
| config_file: .github/kernel-config/a14-5.15.json | |
| ksu_commit: ${{ inputs.ksu_commit || needs.fetch-latest-commits.outputs.ksu_commit }} | |
| anykernel_commit: ${{ needs.fetch-latest-commits.outputs.anykernel_commit }} | |
| patches_commit: ${{ needs.fetch-latest-commits.outputs.patches_commit }} | |
| susfs_commit: ${{ needs.fetch-latest-commits.outputs.susfs_commit }} | |
| feature_set: ${{ inputs.feature_set || 'WKSU+SUSFS+BBG' }} | |
| secrets: inherit | |
| build-a14-6-1: | |
| if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a14-6-1' }} | |
| needs: fetch-latest-commits | |
| uses: ./.github/workflows/prepare.yml | |
| with: | |
| config_file: .github/kernel-config/a14-6.1.json | |
| ksu_commit: ${{ inputs.ksu_commit || needs.fetch-latest-commits.outputs.ksu_commit }} | |
| anykernel_commit: ${{ needs.fetch-latest-commits.outputs.anykernel_commit }} | |
| patches_commit: ${{ needs.fetch-latest-commits.outputs.patches_commit }} | |
| susfs_commit: ${{ needs.fetch-latest-commits.outputs.susfs_commit }} | |
| feature_set: ${{ inputs.feature_set || 'WKSU+SUSFS+BBG' }} | |
| secrets: inherit | |
| build-a15-6-6: | |
| if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a15-6-6' }} | |
| needs: fetch-latest-commits | |
| uses: ./.github/workflows/prepare.yml | |
| with: | |
| config_file: .github/kernel-config/a15-6.6.json | |
| ksu_commit: ${{ inputs.ksu_commit || needs.fetch-latest-commits.outputs.ksu_commit }} | |
| anykernel_commit: ${{ needs.fetch-latest-commits.outputs.anykernel_commit }} | |
| patches_commit: ${{ needs.fetch-latest-commits.outputs.patches_commit }} | |
| susfs_commit: ${{ needs.fetch-latest-commits.outputs.susfs_commit }} | |
| feature_set: ${{ inputs.feature_set || 'WKSU+SUSFS+BBG' }} | |
| secrets: inherit | |
| build-a16-6-12: | |
| if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'a16-6-12' }} | |
| needs: fetch-latest-commits | |
| uses: ./.github/workflows/prepare.yml | |
| with: | |
| config_file: .github/kernel-config/a16-6.12.json | |
| ksu_commit: ${{ inputs.ksu_commit || needs.fetch-latest-commits.outputs.ksu_commit }} | |
| anykernel_commit: ${{ needs.fetch-latest-commits.outputs.anykernel_commit }} | |
| patches_commit: ${{ needs.fetch-latest-commits.outputs.patches_commit }} | |
| susfs_commit: ${{ needs.fetch-latest-commits.outputs.susfs_commit }} | |
| feature_set: ${{ inputs.feature_set || 'WKSU+SUSFS+BBG' }} | |
| secrets: inherit | |
| build-lts: | |
| if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'lts' || github.event_name == 'push' }} | |
| needs: fetch-latest-commits | |
| uses: ./.github/workflows/prepare.yml | |
| with: | |
| config_file: .github/kernel-config/lts.json | |
| ksu_commit: ${{ inputs.ksu_commit || needs.fetch-latest-commits.outputs.ksu_commit }} | |
| anykernel_commit: ${{ needs.fetch-latest-commits.outputs.anykernel_commit }} | |
| patches_commit: ${{ needs.fetch-latest-commits.outputs.patches_commit }} | |
| susfs_commit: ${{ needs.fetch-latest-commits.outputs.susfs_commit }} | |
| feature_set: ${{ inputs.feature_set || 'WKSU+SUSFS+BBG' }} | |
| secrets: inherit | |
| build-custom: | |
| if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'custom' }} | |
| needs: fetch-latest-commits | |
| uses: ./.github/workflows/prepare.yml | |
| with: | |
| config_file: .github/kernel-config/custom.json | |
| ksu_commit: ${{ inputs.ksu_commit || needs.fetch-latest-commits.outputs.ksu_commit }} | |
| anykernel_commit: ${{ needs.fetch-latest-commits.outputs.anykernel_commit }} | |
| patches_commit: ${{ needs.fetch-latest-commits.outputs.patches_commit }} | |
| susfs_commit: ${{ needs.fetch-latest-commits.outputs.susfs_commit }} | |
| feature_set: ${{ inputs.feature_set || 'WKSU+SUSFS+BBG' }} | |
| secrets: inherit | |
| build-testing: | |
| if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'testing' || github.event_name == 'push' }} | |
| needs: fetch-latest-commits | |
| uses: ./.github/workflows/prepare.yml | |
| with: | |
| config_file: .github/kernel-config/testing.json | |
| ksu_commit: ${{ inputs.ksu_commit || needs.fetch-latest-commits.outputs.ksu_commit }} | |
| anykernel_commit: ${{ needs.fetch-latest-commits.outputs.anykernel_commit }} | |
| patches_commit: ${{ needs.fetch-latest-commits.outputs.patches_commit }} | |
| susfs_commit: ${{ needs.fetch-latest-commits.outputs.susfs_commit }} | |
| feature_set: ${{ inputs.feature_set || 'WKSU+SUSFS+BBG' }} | |
| secrets: inherit | |
| build-bypass: | |
| if: ${{ inputs.kernel_build_version == 'all' || inputs.kernel_build_version == 'bypass' }} | |
| needs: fetch-latest-commits | |
| uses: ./.github/workflows/prepare.yml | |
| with: | |
| config_file: .github/kernel-config/bypass.json | |
| ksu_commit: ${{ inputs.ksu_commit || needs.fetch-latest-commits.outputs.ksu_commit }} | |
| anykernel_commit: ${{ needs.fetch-latest-commits.outputs.anykernel_commit }} | |
| patches_commit: ${{ needs.fetch-latest-commits.outputs.patches_commit }} | |
| susfs_commit: ${{ needs.fetch-latest-commits.outputs.susfs_commit }} | |
| feature_set: ${{ inputs.feature_set || 'WKSU+SUSFS+BBG' }} | |
| secrets: inherit | |
| rej: | |
| if: always() | |
| runs-on: ubuntu-latest | |
| permissions: | |
| actions: read | |
| contents: read | |
| needs: | |
| - build-a12-5-10 | |
| - build-a13-5-10 | |
| - build-a13-5-15 | |
| - build-a14-5-15 | |
| - build-a14-6-1 | |
| - build-a15-6-6 | |
| - build-a16-6-12 | |
| - build-custom | |
| - build-lts | |
| - build-testing | |
| - build-bypass | |
| steps: | |
| - name: Download Misc Artifacts | |
| uses: actions/download-artifact@v4 | |
| 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 | |
| # Ensure it is a directory | |
| [ -d "$dir" ] || continue | |
| dirname=$(basename "$dir") | |
| # Process each reject artifact | |
| # Get original name (remove -Rejects suffix) | |
| original_name=${dirname%-Rejects} | |
| mkdir -p "aio-rejects/$original_name" | |
| # Check for patch-rejects folder (legacy structure) or direct contents | |
| if [ -d "$dir/patch-rejects" ]; then | |
| # Legacy structure | |
| cp -r "$dir/patch-rejects/." "aio-rejects/$original_name/" | |
| else | |
| # Current structure | |
| cp -r "$dir/." "aio-rejects/$original_name/" | |
| fi | |
| done | |
| # Zip and upload if we found anything | |
| if [ "$(ls -A aio-rejects)" ]; then | |
| # Create a single zip of all rejects | |
| cd aio-rejects | |
| zip -r -q -9 ../AIO-REJ.zip . | |
| cd .. | |
| else | |
| echo "No rejects found to upload." | |
| fi | |
| - name: Upload AIO-REJ Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: AIO-REJ | |
| path: AIO-REJ.zip | |
| if-no-files-found: ignore | |
| release: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_type != 'Actions' }} | |
| permissions: | |
| contents: write | |
| needs: | |
| - build-a12-5-10 | |
| - build-a13-5-10 | |
| - build-a13-5-15 | |
| - build-a14-5-15 | |
| - build-a14-6-1 | |
| - build-a15-6-6 | |
| - build-a16-6-12 | |
| - build-lts | |
| - build-custom | |
| - build-testing | |
| - build-bypass | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| RELEASE_NAME: "GKI Kernels With WKSU & SUSFS v2.0.0" | |
| RELEASE_BODY: "" | |
| 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 "a12-5-10" "build-a12-5-10" "${{ needs.build-a12-5-10.result }}" | |
| check_selected "a13-5-10" "build-a13-5-10" "${{ needs.build-a13-5-10.result }}" | |
| check_selected "a13-5-15" "build-a13-5-15" "${{ needs.build-a13-5-15.result }}" | |
| check_selected "a14-5-15" "build-a14-5-15" "${{ needs.build-a14-5-15.result }}" | |
| check_selected "a14-6-1" "build-a14-6-1" "${{ needs.build-a14-6-1.result }}" | |
| check_selected "a15-6-6" "build-a15-6-6" "${{ needs.build-a15-6-6.result }}" | |
| check_selected "a16-6-12" "build-a16-6-12" "${{ needs.build-a16-6-12.result }}" | |
| check_selected "custom" "build-custom" "${{ needs.build-custom.result }}" | |
| check_selected "lts" "build-lts" "${{ needs.build-lts.result }}" | |
| check_selected "testing" "build-testing" "${{ needs.build-testing.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@v4 | |
| - name: Generate New Tag | |
| id: tag | |
| if: inputs.release_type != 'Actions' | |
| run: | | |
| LATEST_TAG=$(gh api repos/${{ github.repository }}/tags --jq '.[0].name' 2>/dev/null || echo "v0.0.0") | |
| if [[ -z "$LATEST_TAG" || "$LATEST_TAG" == "null" ]]; then | |
| LATEST_TAG="v0.0.0" | |
| fi | |
| if [[ "$LATEST_TAG" =~ ^(.*)-r([0-9]+)$ ]]; then | |
| VERSION="${BASH_REMATCH[1]}" | |
| REV="${BASH_REMATCH[2]}" | |
| NEW_REV=$((REV + 1)) | |
| NEW_TAG="${VERSION}-r${NEW_REV}" | |
| else | |
| NEW_TAG="${LATEST_TAG}-r1" | |
| fi | |
| echo "Latest tag: $LATEST_TAG" | |
| echo "New tag: $NEW_TAG" | |
| echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV | |
| echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT | |
| - name: Set release body | |
| run: | | |
| cat << 'EOF' > release_body.md | |
| **Automated Release** | |
| This release was automatically generated by GitHub Actions. | |
| **Builds:** | |
| EOF | |
| # Add details about included builds | |
| if [[ "${{ inputs.kernel_build_version }}" == "all" ]]; then | |
| echo "- All Kernel Versions" >> release_body.md | |
| else | |
| echo "- ${{ inputs.kernel_build_version }}" >> release_body.md | |
| fi | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ steps.tag.outputs.new_tag }} | |
| name: ${{ steps.tag.outputs.new_tag }} | |
| body_path: release_body.md | |
| draft: false | |
| prerelease: ${{ inputs.release_type == 'Pre-Release' }} | |
| files: | | |
| AnyKernel3/**/*.zip | |
| AIO-REJ.zip |