Skip to content

Build (5.15.57.1)

Build (5.15.57.1) #12

Workflow file for this run

name: Build WSL2 Kernel
run-name: Build (${{ github.event.inputs.kernel_version }})
on:
workflow_dispatch:
inputs:
kernel_version:
description: "WSL2 kernel version (e.g. 5.15.90.4)"
required: true
default: "5.15.90.4"
jobs:
build-and-release:
runs-on: ubuntu-latest
env:
KERNEL_VERSION: ${{ github.event.inputs.kernel_version }}
KERNEL_DIR: linux-${{ github.event.inputs.kernel_version }}
RELEASE_TAG: v${{ github.event.inputs.kernel_version }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
build-essential flex bison dwarves \
libssl-dev libelf-dev libncurses-dev \
bc rsync cpio python3
- name: Download Kernel Source
run: |
mkdir -p kernel-build
cd kernel-build
wget https://github.com/microsoft/WSL2-Linux-Kernel/archive/refs/tags/linux-msft-wsl-${{ env.KERNEL_VERSION }}.tar.gz
tar -xzf linux-msft-wsl-${{ env.KERNEL_VERSION }}.tar.gz
mv WSL2-Linux-Kernel-linux-msft-wsl-${{ env.KERNEL_VERSION }} linux-${{ env.KERNEL_VERSION }}
echo "KERNEL_DIR=$(pwd)/linux-${{ env.KERNEL_VERSION }}" >> $GITHUB_ENV
- name: Configure Kernel
run: |
cd ${{ env.KERNEL_DIR }}
cp Microsoft/config-wsl .config
./scripts/config --enable LD_NO_EXEC_STACK
./scripts/config --enable INIT_STACK_NONE
./scripts/config --enable DEBUG_INFO_BTF
./scripts/config --set-str DEBUG_INFO_BTF_MODULES ""
make olddefconfig
make -j$(nproc) \
LDFLAGS="-z noexecstack -z separate-code" \
BTF_PAHOLE_FLAGS="--btf_gen_floats"
- name: Build Kernel
run: |
cd ${{ env.KERNEL_DIR }}
make -j$(nproc) LDFLAGS="-z noexecstack -z separate-code" 2>&1 | tee build.log
if [ ! -f arch/x86/boot/bzImage ]; then
echo "::error::Kernel build failed!"
cat build.log | grep -i error
exit 1
fi
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.RELEASE_TAG }}
release_name: "WSL2 Kernel ${{ env.KERNEL_VERSION }}"
body: |
### Build Information
- Version: ${{ env.KERNEL_VERSION }}
- Build Date: $(date -u +'%Y-%m-%d %H:%M:%S')
- Source: [Microsoft/WSL2-Linux-Kernel@${{ env.KERNEL_VERSION }}](https://github.com/microsoft/WSL2-Linux-Kernel/tree/linux-msft-wsl-${{ env.KERNEL_VERSION }})
### Usage
1. Download `bzImage`
2. Place in `C:\Windows\System32\lxss\tools`
3. Add to `.wslconfig`:
```ini
[wsl2]
kernel=C:\\Windows\\System32\\lxss\\tools\\bzImage
```
draft: false
prerelease: false
- name: Upload Kernel Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.KERNEL_DIR }}/arch/x86/boot/bzImage
asset_name: bzImage-${{ env.KERNEL_VERSION }}
asset_content_type: application/octet-stream
- name: Upload Build Log
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.KERNEL_DIR }}/build.log
asset_name: build-log-${{ env.KERNEL_VERSION }}.txt