Debian Kernel Latest #63
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
# | |
# This is free software, licensed under the MIT License. | |
# See /LICENSE for more information. | |
# | |
# Description: Build Kernel using GitHub Actions | |
# Change from P3TERX | |
# | |
name: Debian Kernel Latest | |
on: | |
workflow_dispatch: | |
env: | |
UPLOAD_DIR: true | |
UPLOAD_RELEASE: true | |
UPLOAD_WETRANSFER: false | |
TZ: Asia/Shanghai | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
container: docker.io/qctt/kernelbuild:debian12 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
- name: Get Kernel Versions | |
id: versions | |
run: | | |
github_tag=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep 'Debian_Kernel' | grep '_latest_bbr_' | head -n 1 | awk -F '"' '{print $4}' | awk -F '[/]' '{print $8}') | |
github_ver=$(curl -s 'https://api.github.com/repos/ylx2016/kernel/releases' | grep ${github_tag} | grep 'deb' | grep 'headers' | awk -F '"' '{print $4}' | awk -F '[/]' '{print $9}' | awk -F '[-]' '{print $3}' | awk -F '[_]' '{print $1}') | |
kernel_ver=$(curl -s https://www.kernel.org/ | grep ' <a href="https://cdn.kernel.org/pub/linux/kernel/' | head -n 1 | awk -F '[>]' '{print $2}' | awk -F '[<]' '{print $1}') | |
echo "github_ver=$github_ver" | |
echo "kernel_ver=$kernel_ver" | |
if [ "$github_ver" = *"$kernel_ver"* ]; then | |
echo "action_echo=enabled" >> $GITHUB_ENV | |
echo "versions.status=fail" >> $GITHUB_ENV | |
else | |
echo "action_echo=enabled" >> $GITHUB_ENV | |
echo "versions.status=success" >> $GITHUB_ENV | |
fi | |
echo ${{ env.versions.status }} | |
- name: Get Source Code | |
if: ${{ env.versions.status }} == 'success' | |
working-directory: /workdir | |
run: | | |
df -hT $PWD | |
kernel_file=$(curl -s https://www.kernel.org/ | grep 'alt="Download"' | awk -F '"' '{print $2}') | |
kernel_ver=$(curl -s https://www.kernel.org/ | grep ' <a href="https://cdn.kernel.org/pub/linux/kernel/' | head -n 1 | awk -F '[>]' '{print $2}' | awk -F '[<]' '{print $1}') | |
wget -O kernel.tar.xz $kernel_file | |
tar -Jxvf kernel.tar.xz -C /workdir && cd /workdir/linux-$kernel_ver | |
echo "action_echo=enabled" >> $GITHUB_ENV | |
echo "code.status=success" >> $GITHUB_ENV | |
- name: Compile Kernel | |
if: ${{ env.versions.status }} == 'success' && ${{ env.code.status }} == 'success' | |
working-directory: /workdir | |
run: | | |
kernel_ver=$(curl -s https://www.kernel.org/ | grep ' <a href="https://cdn.kernel.org/pub/linux/kernel/' | head -n 1 | awk -F '[>]' '{print $2}' | awk -F '[<]' '{print $1}') | |
cd linux-$kernel_ver | |
wget -O .config https://raw.githubusercontent.com/ylx2016/kernel/master/config_elrepo | |
sed -ri '/CONFIG_SYSTEM_TRUSTED_KEYS/s/=.+/=""/g' .config | |
scripts/config --disable MODULE_SIG | |
scripts/config --disable DEBUG_INFO | |
scripts/config --disable DEBUG_INFO_BTF | |
scripts/config --disable DEBUG_INFO_DWARF4 | |
scripts/config --disable DEBUG_INFO_DWARF5 | |
scripts/config --disable DEBUG_INFO_NONE | |
scripts/config --disable SYSTEM_TRUSTED_KEYS | |
scripts/config --disable SYSTEM_REVOCATION_KEYS | |
echo -e "$(nproc) thread compile" | |
sudo time make -j$(nproc) bindeb-pkg | |
cd /workdir && mv *.deb /workdir/upload | |
echo "action_echo=enabled" >> $GITHUB_ENV | |
echo "compile.status=success" >> $GITHUB_ENV | |
echo "FILE_DATE=Kernel_Debian_$kernel_ver_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@main | |
if: ${{ env.compile.status }} == 'success' && ${{ env.UPLOAD_DIR }} == 'true' | |
with: | |
name: ${{ env.FILE_DATE }} | |
path: /workdir/upload | |
- name: Upload to WeTransfer | |
if: ${{ env.compile.status }} == 'success' && ${{ env.UPLOAD_WETRANSFER }} == 'true' && !cancelled() | |
run: | | |
curl -fsSL git.io/file-transfer | sh | |
./transfer wet -s -p 16 --no-progress /workdir/upload 2>&1 | tee wetransfer.log | |
echo "::warning file=wetransfer.com::$(grep https wetransfer.log)" | |
echo "action_echo=enabled" >> $GITHUB_ENV | |
echo "url=$(grep https wetransfer.log | cut -f3 -d' ')" >> $GITHUB_ENV | |
- name: Generate release tag | |
id: tag | |
if: ${{ env.UPLOAD_RELEASE }} == 'true' && ${{ env.compile }} = == 'success' && !cancelled() | |
run: | | |
kernel_ver=$(curl -s https://www.kernel.org/ | grep ' <a href="https://cdn.kernel.org/pub/linux/kernel/' | head -n 1 | awk -F '[>]' '{print $2}' | awk -F '[<]' '{print $1}') | |
echo "action_echo=enabled" >> $GITHUB_ENV | |
echo "release_tag=Debian_Kernel_${kernel_ver}_latest_bbr_$(date +"%Y.%m.%d-%H%M")" >> $GITHUB_ENV | |
touch release.txt | |
echo "tag.status=success" >> $GITHUB_ENV | |
- name: Upload Kernel to release | |
uses: softprops/action-gh-release@v1 | |
if: ${{ env.tag.status }} == 'success' && !cancelled() | |
env: | |
GITHUB_TOKEN: ${{ secrets.TOKEN }} | |
with: | |
tag_name: ${{ env.release_tag }} | |
body_path: release.txt | |
files: /workdir/upload/* | |
- name: Delete workflow runs | |
uses: GitRML/delete-workflow-runs@main | |
with: | |
token: ${{ secrets.TOKEN }} | |
repository: ${{ github.repository }} | |
retain_days: 1 | |
keep_minimum_runs: 2 |