Skip to content

Build Kernel Customize #6

Build Kernel Customize

Build Kernel Customize #6

name: Build Kernel Customize
on:
workflow_dispatch:
inputs:
BOARD:
description: 'Board type'
required: true
default: 'tpm312'
type: choice
options:
- emb3531
- fine3399
- fmx1-pro
- r08
- rock960
- sg2710
- tpm312
- tb-ls3399
- xiaobao-nas
- zysj
BRANCH:
description: 'Armbian kernel branch'
default: 'current'
required: false
type: choice
options:
- stable
- current
- edge
Version:
description: 'Armbian Version'
default: 'v24.11'
required: false
type: choice
options:
- main
- v24.11
- v24.08
env:
TZ: America/New_York
jobs:
build-armbian-kernel:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Initialization environment
id: init
env:
DEBIAN_FRONTEND: noninteractive
run: |
# 清理 Docker 镜像和软件缓存
docker_images_ids=$(docker images -q)
if [ -n "$docker_images_ids" ]; then
docker rmi $docker_images_ids
fi
docker image prune -a -f
sudo -E apt-get -y purge azure-cli ghc* zulu* llvm* firefox google* dotnet* openjdk* mysql* php* mongodb* dotnet* moby* snapd* android* || true
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
# 设置时区并创建工作目录
sudo timedatectl set-timezone "${TZ}"
sudo mkdir -p /mnt/workdir
sudo chown $USER:$GROUPS /mnt/workdir
df -Th
- name: Download source code
working-directory: /mnt/workdir
run: |
df -hT ${PWD}
git clone -q --single-branch --depth=1 --branch=${{ github.event.inputs.Version }} https://github.com/armbian/build.git build
ln -sf /mnt/workdir/build $GITHUB_WORKSPACE/build
cd build/
# 复制 config 和 userpatches 目录文件
cp -rf ${{ github.workspace }}/addboard/config/* config
mkdir -p userpatches
cp -rf ${{ github.workspace }}/addboard/userpatches/* userpatches
ls -la
- name: Compile Kernel [ ${{ inputs.BOARD }} ${{ inputs.BRANCH }} ]
run: |
cd /mnt/workdir/build/
./compile.sh kernel BOARD=${{ inputs.BOARD }} BRANCH=${{ inputs.BRANCH }} DEB_COMPRESS=xz
- name: Prepare Kernel
run: |
cd "${GITHUB_WORKSPACE}/build/output/debs/"
file=$(find . -maxdepth 1 -type f -name 'linux-image-*.deb' | head -n 1)
if [ -n "$file" ]; then
echo "Found file: $file"
KERNEL_VERSION=$(echo "$file" | cut -d '_' -f 5 | cut -d '-' -f 1)
echo "KERNEL_VERSION=$KERNEL_VERSION" >> $GITHUB_ENV
echo "Extracted KERNEL_VERSION: $KERNEL_VERSION"
else
echo "No matching file found. Available files are:"
ls -1 "${GITHUB_WORKSPACE}/build/output/debs/"
exit 1
fi
matching_files_array=($(ls linux-dtb* linux-headers* linux-image* linux-libc* 2>/dev/null))
if [ ${#matching_files_array[@]} -gt 0 ]; then
tar -czf "../kernel-${KERNEL_VERSION}-${{ inputs.BRANCH }}-${{ inputs.BOARD }}.tar.gz" "${matching_files_array[@]}"
echo "Compressed matching files to kernel-${KERNEL_VERSION}-${{ inputs.BRANCH }}-${{ inputs.BOARD }}.tar.gz"
else
echo "No matching files found for compression."
exit 1
fi
tar -tzf "../kernel-${KERNEL_VERSION}-${{ inputs.BRANCH }}-${{ inputs.BOARD }}.tar.gz" || { echo "Failed to create valid tar.gz file"; exit 1; }
- name: Upload Kernel Packages to Release
if: success()
uses: ncipollo/release-action@main
with:
tag: "Armbian_Kernel"
name: "Armbian_Kernel"
artifacts: "${{ github.workspace }}/build/output/kernel-${{ env.KERNEL_VERSION }}-${{ inputs.BRANCH }}-${{ inputs.BOARD }}.tar.gz"
allowUpdates: true
removeArtifacts: false
replacesArtifacts: true
token: ${{ secrets.MY_TOKEN }}
body: |
### Armbian Kernel Packages
- The kernel can be used to compile Armbian
- Usage method: After unzipping, install the deb packages in order
- Deb Packages: linux-dtb | linux-headers | linux-image | linux-libc-dev
draft: false
prerelease: false