Skip to content

Build pve-kernel

Build pve-kernel #3

name: Build pve-kernel
on:
workflow_dispatch:
inputs:
tmate_debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
runner:
description: 'Target runner for this workflow'
required: true
type: choice
options:
- ubuntu-22.04
- self-hosted
default: 'ubuntu-22.04'
repo-url:
description: 'URL for the Proxmox kernel repository'
required: false
type: string
default: 'git://git.proxmox.com/git/pve-kernel.git'
branch:
description: 'Branch to build'
required: true
type: string
upload-artifacts:
description: 'Upload artifacts'
required: false
type: boolean
default: true
workflow_call:
inputs:
tmate_debug_enabled:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
runner:
description: 'Target runner for this workflow'
type: string
default: 'ubuntu-22.04'
repo-url:
description: 'URL for the Proxmox kernel repository'
required: false
type: string
default: 'git://git.proxmox.com/git/pve-kernel.git'
branch:
description: 'Branch to build'
required: true
type: string
upload-artifacts:
description: 'Control whether artifacts should be uploaded'
required: false
type: boolean
default: true
outputs:
build-successful:
description: 'Build was successful'
value: ${{ jobs.build.outputs.build-successful }}
kernel-version:
description: 'Kernel version built'
value: ${{ jobs.build.outputs.kernel-version }}
artifacts-name:
description: 'Artifact named used'
value: ${{ jobs.build.outputs.artifacts-name }}
env:
DEBIAN_RELEASE: bullseye
jobs:
build:
name: Build PVE kernel
runs-on: ${{ inputs.runner }}
outputs:
build-successful: ${{ steps.docker-build.outputs.status == 'success' }}
kernel-version: ${{ steps.kernel-version.outputs.version }}
# For now, use kernel version as the artifacts name
artifacts-name: ${{ steps.kernel-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@master
- name: Cleanup
env:
DEBIAN_FRONTEND: noninteractive
run: |
set -x
echo "Disk usage: start"
df -h
sudo -E apt-get update
packages="'aspnetcore-targeting-pack.*' '^dotnet-.*' '^temurin-.*-jdk' '^llvm-.*' 'php.*' google-cloud-sdk google-cloud-cli \
azure-cli microsoft-edge-stable google-chrome-stable firefox 'openjdk-11-.*' powershell 'postgresql-.*' 'mysql-.*-core-.*' \
mono-devel 'mono-llvm-.*' 'gfortran-.*'"
# Adding cat at the end to reset the exit status to 0 in case grep doesn't find anything
packages_to_remove=$(dpkg -l | grep -E '^ii' | awk '{ print $2 }' | eval grep -E $(printf " -e %s" $packages) | cat)
if [ -n "${packages_to_remove}" ]; then
echo "Removing packages: ${packages_to_remove}"
sudo -E apt-get purge -y ${packages_to_remove}
sudo -E apt-get autoremove -y
sudo -E apt-get clean
echo "Disk usage: after apt-get purge"
df -h
fi
sudo -E rm -rf /usr/share/dotnet /usr/local/lib/android /usr/local/share/powershell /usr/local/share/chromium \
/usr/share/swift /opt/hostedtoolcache/PyPy /usr/local/julia1.10.0 /usr/local/aws-cli
echo "Disk usage: after directory removals"
df -h
echo "Top packages by size:"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -rn | tail -n 100
sudo -E du -d 4 -ahx / | sort -rh | tail -n 100
- name: Initialize environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get upgrade -y
sudo -E apt-get install -y --no-install-recommends apt-utils git nano
- name: Prepare container
run: |
docker build --build-arg DEBIAN_RELEASE=${DEBIAN_RELEASE} --build-arg REPO_URL="${{ inputs.repo-url }}" \
--build-arg REPO_BRANCH="${{ inputs.branch }}" -t pve-kernel-build .
- name: Build kernel
id: docker-build
run: |
mkdir output
chmod 777 output
docker run -v ${{ github.workspace }}/output:/build/output pve-kernel-build scripts/build-kernel.sh
echo "status=success" >> $GITHUB_OUTPUT
- name: Extract kernel version
id: kernel-version
run: |
cd output
echo "version=$(ls abi-[0-9]* | sed 's/abi/pve-kernel/g' | sed 's/-pve//g')" >> $GITHUB_OUTPUT
- name: Upload build artifacts
uses: actions/upload-artifact@master
if: steps.docker-build.outputs.status == 'success' && inputs.upload-artifacts
with:
name: ${{ steps.kernel-version.outputs.version }}
path: ./output/artifacts
- name: Start tmate session on failure
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.tmate_debug_enabled && failure() }}