diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index df0a2b5..66ee484 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,10 +25,16 @@ jobs: - name: Checkout Repository uses: actions/checkout@v4 + - name: Upload LKM Source Code + uses: actions/upload-artifact@v4 + with: + name: hello-ko-${{ matrix.tag }}-${{ matrix.arch }} + path: .github/hello-ko + - name: Run GKI Kernel Build Action uses: ./ with: - tag: ${{ matrix.tag }} arch: ${{ matrix.arch }} - module-path: .github/hello-ko + tag: ${{ matrix.tag }} module-name: hello-ko + module-path: hello-ko-${{ matrix.tag }}-${{ matrix.arch }} diff --git a/README.md b/README.md index abb6f60..d9c4baf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Android Kernel Build Action -This GitHub Action is designed to automate the building of Android kernel modules out of the kernel source. It supports both aarch64 and x86_64 architectures, and can build kernels for different Android versions (GKI 2.0). +This GitHub Action is designed to automate the building of Android kernel modules out of the kernel source. It supports both aarch64 and x86_64 architectures, and can build kernels for different Android versions (GKI 2.0/3.0). ## Overview @@ -28,20 +28,6 @@ The Android Kernel Build Action allows users to easily build kernels for Android ### Required Inputs -- kernel-url: - - - Description: URL of the kernel source to be used. - - - Required: true - -- config: - - - Description: Kernel configuration to be used for the build. - - - Required: true - - - Default: defconfig - - arch: - Description: Target architecture for the kernel build. @@ -50,24 +36,25 @@ The Android Kernel Build Action allows users to easily build kernels for Android - Default: arm64 -- android-version: +- tag: - - Description: Android version for which the kernel is being built. + - Description: Android GKI version. - Required: true - - Default: 12 + - Default: 'android13-5.15' -### Optional Inputs +- module-name: -- depth: + - Description: module name of the ko. - - Description: Depth for the kernel source git clone. + - Required: true - - Required: false +- module-path - - Default: 1 + - Description: module name of the github action artifact. + - Required: true ## Usage Example @@ -110,19 +97,21 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Kernel Build - uses: feicong/android-kernel-build-action@main + - name: Upload LKM Source Code + uses: actions/upload-artifact@v4 + with: + name: hello-ko-${{ matrix.tag }}-${{ matrix.arch }} + path: .github/hello-ko + + - name: Run GKI Kernel Build Action + uses: ./ with: arch: ${{ matrix.arch }} tag: ${{ matrix.tag }} - module-path: .github/hello-ko module-name: hello-ko + module-path: hello-ko-${{ matrix.tag }}-${{ matrix.arch }} ``` -### Explanation of Parameters - -arch: Specifies the architecture for which the kernel should be built (aarch64 or x86_64). - ### Outputs -The action will upload the compiled kernel. \ No newline at end of file +The action will upload the compiled kernel and module ko file. \ No newline at end of file diff --git a/action.yml b/action.yml index e369612..0069853 100644 --- a/action.yml +++ b/action.yml @@ -7,14 +7,15 @@ branding: inputs: tag: - description: 'Specify the Android kernel version and tag to build for (e.g., common-android12-5.10).' + description: 'Specify the Android kernel version and tag to build for (e.g., android13-5.15).' + default: 'android13-5.15' required: true arch: description: 'Specify the architecture to build for (e.g., aarch64 or x86_64).' required: true default: 'aarch64' module-path: - description: 'Specify the path to the kernel module driver directory.' + description: 'Specify the name of the kernel module artifact.' required: true module-name: description: 'Specify the name of the kernel module.' @@ -23,6 +24,12 @@ inputs: runs: using: "composite" steps: + - name: Download + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.module-path }} + path: ${{ inputs.module-name }} + - name: Validate Input shell: bash run: | @@ -31,16 +38,17 @@ runs: echo "Invalid tag specified: ${{ inputs.tag }}. Must be one of: ${VALID_TAGS[@]}" exit 1 fi - if [ ! -d "${{ inputs.module-path }}" ]; then - echo "Invalid module-path: Directory ${{ inputs.module-path }} does not exist." + if [ ! -d "${{ inputs.module-name }}" ]; then + echo "Invalid module-name: Directory ${{ inputs.module-name }} does not exist." exit 2 fi - if [ ! -f "${{ inputs.module-path }}/Makefile" ]; then - echo "${{ inputs.module-path }}/Makefile does not exist." + ls -l ${{ inputs.module-name }} + if [ ! -f "${{ inputs.module-name }}/Makefile" ]; then + echo "${{ inputs.module-name }}/Makefile does not exist." exit 3 fi - if [ ! -f "${{ inputs.module-path }}/${{ inputs.module-name }}.c" ]; then - echo "Error: ${inputs.module-path}/${inputs.module-name}.c does not exist." + if [ ! -f "${{ inputs.module-name }}/${{ inputs.module-name }}.c" ]; then + echo "Error: ${inputs.module-name}/${inputs.module-name}.c does not exist." exit 4 fi @@ -82,12 +90,12 @@ runs: GKI_ROOT=$GITHUB_WORKSPACE/android-kernel echo "[+] GKI_ROOT: $GKI_ROOT" echo "[+] Copy driver to $GKI_ROOT/common/drivers" - ln -sf $GITHUB_WORKSPACE/${{ inputs.module-path }} $GKI_ROOT/common/drivers/${{ inputs.module-name }} + ln -sf $GITHUB_WORKSPACE/${{ inputs.module-name }} $GKI_ROOT/common/drivers/${{ inputs.module-name }} echo "[+] Add driver to Makefile" DRIVER_MAKEFILE=$GKI_ROOT/common/drivers/Makefile DRIVER_KCONFIG=$GKI_ROOT/common/drivers/Kconfig grep -q "${{ inputs.module-name }}" "$DRIVER_MAKEFILE" || printf "\nobj-m += ${{ inputs.module-name }}/\n" >> "$DRIVER_MAKEFILE" - if [ -f $GITHUB_WORKSPACE/${{ inputs.module-path }}/Kconfig ]; then + if [ -f $GITHUB_WORKSPACE/${{ inputs.module-name }}/Kconfig ]; then grep -q "${{ inputs.module-name }}" "$DRIVER_KCONFIG" || sed -i "/endmenu/i\\source \"drivers/${{ inputs.module-name }}/Kconfig\"" "$DRIVER_KCONFIG" fi # Ensure module Makefile exists