Build and Release GKI Kernels #473
This file contains 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 and Release GKI Kernels | |
permissions: | |
contents: write # Allow writing to repository contents (for pushing tags) | |
actions: write # Allows triggering actions | |
on: | |
workflow_dispatch: | |
inputs: | |
make_release: | |
description: 'Do you want to create a release?' | |
required: true | |
type: boolean | |
default: true | |
kernelsu_variant: | |
description: "Choose KernelSU" | |
required: true | |
type: choice | |
options: | |
- Official | |
- Next | |
- MKSU | |
default: Next | |
kernelsu_branch: | |
description: "Choose ksu branch" | |
required: true | |
type: choice | |
options: | |
- Stable | |
- Dev | |
- Other | |
default: Stable | |
kernelsu_branch_other: | |
description: "If 'Other' is selected, specify your custom branch" | |
required: false | |
type: string # This input is required if 'Other' is chosen | |
default: "" # Default is empty, but can be filled in if 'Other' is selected | |
jobs: | |
build-kernel-a12-5-10: | |
uses: ./.github/workflows/kernel-a12-5.10.yml | |
secrets: inherit | |
with: | |
kernelsu_variant: ${{ inputs.kernelsu_variant }} | |
kernelsu_branch: ${{ inputs.kernelsu_branch }} | |
kernelsu_branch_other: ${{ inputs.kernelsu_branch_other }} | |
build-kernel-a13-5-10: | |
uses: ./.github/workflows/kernel-a13-5.10.yml | |
secrets: inherit | |
with: | |
kernelsu_variant: ${{ inputs.kernelsu_variant }} | |
kernelsu_branch: ${{ inputs.kernelsu_branch }} | |
kernelsu_branch_other: ${{ inputs.kernelsu_branch_other }} | |
build-kernel-a13-5-15: | |
uses: ./.github/workflows/kernel-a13-5.15.yml | |
secrets: inherit | |
with: | |
kernelsu_variant: ${{ inputs.kernelsu_variant }} | |
kernelsu_branch: ${{ inputs.kernelsu_branch }} | |
kernelsu_branch_other: ${{ inputs.kernelsu_branch_other }} | |
build-kernel-a14-5-15: | |
uses: ./.github/workflows/kernel-a14-5.15.yml | |
secrets: inherit | |
with: | |
kernelsu_variant: ${{ inputs.kernelsu_variant }} | |
kernelsu_branch: ${{ inputs.kernelsu_branch }} | |
kernelsu_branch_other: ${{ inputs.kernelsu_branch_other }} | |
build-kernel-a14-6-1: | |
uses: ./.github/workflows/kernel-a14-6.1.yml | |
secrets: inherit | |
with: | |
kernelsu_variant: ${{ inputs.kernelsu_variant }} | |
kernelsu_branch: ${{ inputs.kernelsu_branch }} | |
kernelsu_branch_other: ${{ inputs.kernelsu_branch_other }} | |
build-kernel-a15-6-6: | |
uses: ./.github/workflows/kernel-a15-6.6.yml | |
secrets: inherit | |
with: | |
kernelsu_variant: ${{ inputs.kernelsu_variant }} | |
kernelsu_branch: ${{ inputs.kernelsu_branch }} | |
kernelsu_branch_other: ${{ inputs.kernelsu_branch_other }} | |
trigger-release: | |
runs-on: ubuntu-latest | |
needs: | |
- build-kernel-a12-5-10 | |
- build-kernel-a13-5-10 | |
- build-kernel-a13-5-15 | |
- build-kernel-a14-5-15 | |
- build-kernel-a14-6-1 | |
- build-kernel-a15-6-6 | |
if: ${{ inputs.make_release }} | |
env: | |
REPO_OWNER: WildPlusKernel | |
REPO_NAME: GKI_KernelSU_SUSFS | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
RELEASE_NAME: "*TEST BUILD* GKI Kernels With KernelSU-${{ inputs.kernelsu_variant }} ${{ inputs.kernelsu_branch }} & SUSFS v1.5.5 *TEST BUILD*" | |
RELEASE_NOTES: | | |
This release contains KernelSU-${{ inputs.kernelsu_variant }} ${{ inputs.kernelsu_branch }} and SUSFS v1.5.5 | |
Features: | |
-> KernelSU-${{ inputs.kernelsu_variant }}-${{ inputs.kernelsu_branch }} | |
-> SUSFS ඞ v1.5.5 | |
-> Manual Hooks for Better Hiding | |
-> Wireguard Support | |
-> Simple Maphide for LineageOS Detections | |
-> Futile Maphide for jit-zygote-cache Detections | |
-> Magic Mount Support | |
-> BBRv3 on 5.10-6.1 | |
Notes: | |
-> SUS SU Mode 2 will show as disabled or not compatble due to non-kprobe hooks and is not needed anymore! | |
Module: | |
-> https://github.com/sidex15/ksu_module_susfs | |
steps: | |
# Checkout the code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Determine the branch for KernelSU-${{ inputs.kernelsu_variant }} | |
if: ${{ inputs.kernelsu_branch == 'Dev' || inputs.kernelsu_variant == 'MKSU' }} | |
run: | | |
# Determine the branch based on user input | |
if [[ "${{ inputs.kernelsu_variant }}" == "Official" || "${{ inputs.kernelsu_variant }}" == "MKSU" ]]; then | |
BRANCH="main" | |
elif [[ "${{ inputs.kernelsu_variant }}" == "Next" ]]; then | |
BRANCH="next" | |
elif [[ "${{ inputs.kernelsu_branch }}" == "Other" && -n "${{ inputs.kernelsu_branch_other }}" ]]; then | |
BRANCH="${{ inputs.kernelsu_branch_other }}" | |
else | |
echo "Error: Custom branch not provided for 'Other'" >&2 | |
exit 1 | |
fi | |
# Store the selected branch in GITHUB_ENV | |
echo "KSU_BRANCH=$BRANCH" >> $GITHUB_ENV | |
- name: Get commit hash or tag and generate URL for KernelSU-${{ inputs.kernelsu_variant }} | |
run: | | |
if [ "${{ inputs.kernelsu_variant }}" == "Official" ]; then | |
echo "This is the Official variant" | |
REPO_URL="https://github.com/tiann/KernelSU.git" | |
REPO_URL2="tiann/KernelSU" | |
elif [ "${{ inputs.kernelsu_variant }}" == "Next" ]; then | |
echo "This is the Next variant" | |
REPO_URL="https://github.com/KernelSU-Next/KernelSU-Next.git" | |
REPO_URL2="KernelSU-Next/KernelSU-Next" | |
elif [ "${{ inputs.kernelsu_variant }}" == "MKSU" ]; then | |
echo "This is the MKSU variant" | |
REPO_URL="https://github.com/5ec1cff/KernelSU.git" | |
REPO_URL2="5ec1cff/KernelSU" | |
else | |
echo "Unknown variant" | |
fi | |
if [[ "${{ inputs.kernelsu_branch }}" == "Stable" && "${{ inputs.kernelsu_variant }}" != "MKSU" ]]; then | |
# Fetch the latest tag | |
TAG=$(git ls-remote --tags --sort=-v:refname $REPO_URL | grep -o 'refs/tags/.*' | cut -d'/' -f3 | head -n1) | |
if [[ -z "$TAG" ]]; then | |
echo "Error: Could not fetch latest tag for Stable" >&2 | |
exit 1 | |
fi | |
KSU_REF=$TAG | |
KSU_URL="https://github.com/$REPO_URL2/releases/tag/$TAG" | |
elif [[ "${{ inputs.kernelsu_branch }}" == "Dev" || "${{ inputs.kernelsu_variant }}" == "MKSU" ]]; then | |
# Fetch the latest commit from "next" branch | |
COMMIT_HASH=$(git ls-remote $REPO_URL refs/heads/$KSU_BRANCH | awk '{ print $1 }') | |
if [[ -z "$COMMIT_HASH" ]]; then | |
echo "Error: Could not fetch latest commit for Dev" >&2 | |
exit 1 | |
fi | |
KSU_REF=$COMMIT_HASH | |
KSU_URL="https://github.com/$REPO_URL2/commit/$COMMIT_HASH" | |
else | |
# Fetch the specific tag | |
TAG=${{ inputs.kernelsu_branch_other }} | |
if git ls-remote --tags $REPO_URL | grep -q "refs/tags/$TAG"; then | |
KSU_REF=$TAG | |
KSU_URL="https://github.com/$REPO_URL2/releases/tag/$TAG" | |
else | |
echo "Error: Specified tag '$TAG' not found in KernelSU-Next" >&2 | |
exit 1 | |
fi | |
fi | |
# Echo the values to GitHub environment for later use | |
echo "KSU_REF=$KSU_REF" >> $GITHUB_ENV | |
echo "KSU_URL=$KSU_URL" >> $GITHUB_ENV | |
echo "KernelSU Reference: $KSU_REF" | |
echo "KernelSU URL: $KSU_URL" | |
- name: Get commit hashes and generate commit URLs | |
run: | | |
GITLAB_OWNER="simonpunk" | |
GITLAB_REPO="susfs4ksu" | |
declare -A BRANCH_MAP=( | |
["gki_android12_5_10"]="gki-android12-5.10" | |
["gki_android13_5_10"]="gki-android13-5.10" | |
["gki_android13_5_15"]="gki-android13-5.15" | |
["gki_android14_5_15"]="gki-android14-5.15" | |
["gki_android14_6_1"]="gki-android14-6.1" | |
) | |
for var_name in "${!BRANCH_MAP[@]}"; do | |
branch_name="${BRANCH_MAP[$var_name]}" | |
COMMIT_HASH=$(git ls-remote https://gitlab.com/$GITLAB_OWNER/$GITLAB_REPO.git refs/heads/$branch_name | awk '{ print $1 }') | |
if [[ -n "$COMMIT_HASH" ]]; then | |
COMMIT_URL="https://gitlab.com/$GITLAB_OWNER/$GITLAB_REPO/-/commit/$COMMIT_HASH" | |
echo "$branch_name Commit: $COMMIT_HASH" | |
echo "$branch_name Commit URL: $COMMIT_URL" | |
# Store commit hash and commit URL in GitHub environment | |
echo "COMMIT_HASH_${var_name}=$COMMIT_HASH" >> "$GITHUB_ENV" | |
echo "COMMIT_URL_${var_name}=$COMMIT_URL" >> "$GITHUB_ENV" | |
fi | |
done | |
- name: Append Commit Hashes & Links to `RELEASE_NOTES` & Append KernelSU-Next Reference to `RELEASE_NOTES` | |
run: | | |
if [ "${{ inputs.kernelsu_variant }}" == "Official" ]; then | |
echo "This is the Official variant" | |
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV | |
echo "$RELEASE_NOTES" >> $GITHUB_ENV | |
echo "Official Manager:" >> $GITHUB_ENV | |
echo "-> https://github.com/tiann/KernelSU" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
elif [ "${{ inputs.kernelsu_variant }}" == "Next" ]; then | |
echo "This is the Next variant" | |
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV | |
echo "$RELEASE_NOTES" >> $GITHUB_ENV | |
echo "Next Manager:" >> $GITHUB_ENV | |
echo "-> https://github.com/KernelSU-Next/KernelSU-Next" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
elif [ "${{ inputs.kernelsu_variant }}" == "MKSU" ]; then | |
echo "This is the MKSU variant" | |
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV | |
echo "$RELEASE_NOTES" >> $GITHUB_ENV | |
echo "MKSU Manager:" >> $GITHUB_ENV | |
echo "-> https://github.com/5ec1cff/KernelSU" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
else | |
echo "Unknown variant" | |
fi | |
- name: Append Commit Hashes & Links to `RELEASE_NOTES` & Append KernelSU-Next Reference to `RELEASE_NOTES` | |
run: | | |
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV | |
echo "$RELEASE_NOTES" >> $GITHUB_ENV | |
echo "" >> $GITHUB_ENV | |
echo "LTO: thin" >> $GITHUB_ENV | |
echo "" >> $GITHUB_ENV | |
echo "Commit Hashes and Links:" >> $GITHUB_ENV | |
echo "KernelSU:" >> $GITHUB_ENV | |
echo "${{ inputs.kernelsu_variant }}-${{ inputs.kernelsu_branch }}: [$KSU_REF]($KSU_URL)" >> $GITHUB_ENV | |
echo "SUSFS4KSU:" >> $GITHUB_ENV | |
echo "gki-android12-5.10: [$COMMIT_HASH_gki_android12_5_10]($COMMIT_URL_gki_android12_5_10)" >> $GITHUB_ENV | |
echo "gki-android13-5.10: [$COMMIT_HASH_gki_android13_5_10]($COMMIT_URL_gki_android13_5_10)" >> $GITHUB_ENV | |
echo "gki-android13-5.15: [$COMMIT_HASH_gki_android13_5_15]($COMMIT_URL_gki_android13_5_15)" >> $GITHUB_ENV | |
echo "gki-android14-5.15: [$COMMIT_HASH_gki_android14_5_15]($COMMIT_URL_gki_android14_5_15)" >> $GITHUB_ENV | |
echo "gki-android14-6.1: [$COMMIT_HASH_gki_android14_6_1]($COMMIT_URL_gki_android14_6_1)" >> $GITHUB_ENV | |
echo "" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
# Get the Latest Tag from GitHub | |
- name: Generate and Create New Tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Fetch the latest tag from GitHub (this is the latest tag based on the GitHub API) | |
LATEST_TAG=$(gh api repos/$REPO_OWNER/$REPO_NAME/tags --jq '.[0].name') | |
if [ -z "$LATEST_TAG" ]; then | |
LATEST_TAG="v1.5.5-r0" | |
fi | |
NEW_TAG=$(echo "$LATEST_TAG" | awk -F'-r' '{suffix=$2; if (!suffix) suffix=0; suffix++; printf "%s-r%d", $1, suffix}') | |
# Output the new tag to be used | |
echo "New tag: $NEW_TAG" | |
# Set the new tag as an environment variable to be used in later steps | |
echo "NEW_TAG=${NEW_TAG}" >> $GITHUB_ENV | |
# Create the tag in the repository | |
git tag $NEW_TAG | |
git push --tags | |
# Download Artifacts for A12 (Only if A12 Build is successful or input is true or empty) | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ./downloaded-artifacts | |
# Create GitHub Release and upload files if make_release is true | |
- name: Create GitHub Release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ env.NEW_TAG }} # Use the generated tag for the release | |
prerelease: true # Mark the release as a pre-release | |
release_name: ${{ env.RELEASE_NAME }} # Pass the RELEASE_NAME to the action | |
body: ${{ env.RELEASE_NOTES }} # Pass the RELEASE_NOTES to the action | |
- name: Upload Release Assets Dynamically | |
run: | | |
# Loop through all files in the downloaded-artifacts directory | |
for file in ./downloaded-artifacts/kernel-*/*; do | |
# Skip directories | |
if [ -d "$file" ]; then | |
continue | |
fi | |
# Upload the file to the GitHub release | |
echo "Uploading $file..." | |
gh release upload ${{ env.NEW_TAG }} "$file" | |
done | |
# Display Files Uploaded | |
- name: Display Files Uploaded | |
run: | | |
echo "GitHub release created with the following files:" | |
ls ./downloaded-artifacts/**/* | |
- name: send telegram message on push | |
env: | |
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
TELEGRAM_MESSAGE_THREAD_ID: ${{ secrets.TELEGRAM_MESSAGE_THREAD_ID }} | |
run: | | |
curl -X POST "https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage" \ | |
-d "chat_id=$TELEGRAM_CHAT_ID" \ | |
-d "message_thread_id=$TELEGRAM_MESSAGE_THREAD_ID" \ | |
-d "text=Latest release: | |
https://github.com/WildPlusKernel/GKI_KernelSU_SUSFS/releases/tag/${{ env.NEW_TAG }} | |
${{ env.RELEASE_NOTES }}" |