Build #2
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
name: Build | |
on: [workflow_dispatch] | |
jobs: | |
build: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04, ubuntu-20.04] | |
kernel: [{ack: 0, version: 5.10.y}, {ack: 0, version: 5.15.y}, {ack: 0, version: 6.1.y}, {ack: 0, version: 6.6.y}, {ack: 1, version: android13-5.10-lts}, {ack: 1, version: android14-5.15-lts}] | |
arch: [arm64, x86_64] | |
runs-on: ${{ matrix.os }} | |
timeout-minutes: 100 | |
env: | |
ACK: ${{ matrix.kernel.ack }} | |
ARCH: ${{ matrix.arch }} | |
outputs: | |
SHORT_HASH: ${{ steps.vars.outputs.SHORT_HASH }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set output variables | |
id: vars | |
run: | | |
set -x | |
SHORT_HASH=$(git rev-parse --short HEAD) | |
if [ $ACK -eq 0 ]; then | |
KERNEL_TYPE=linux | |
OUT_DIR=out/linux/${ARCH} | |
else | |
KERNEL_TYPE=ack | |
OUT_DIR=out/ack/common/${ARCH} | |
fi | |
if [ $ARCH == x86_64 ]; then | |
# We need to use the real image in the x86 folder because caching | |
# doesn't work with symlinks | |
KERNEL_IMAGE="${OUT_DIR}/arch/x86/boot/bzImage" | |
elif [ $ARCH == arm64 ]; then | |
KERNEL_IMAGE="${OUT_DIR}/arch/${ARCH}/boot/Image" | |
fi | |
echo "SHORT_HASH=$SHORT_HASH" >> $GITHUB_OUTPUT | |
echo "OUT_DIR=$OUT_DIR" >> $GITHUB_OUTPUT | |
echo "KERNEL_TYPE=$KERNEL_TYPE" >> $GITHUB_OUTPUT | |
echo "KERNEL_IMAGE=$KERNEL_IMAGE" >> $GITHUB_OUTPUT | |
- name: Get real kernel version | |
run: | | |
LINUX_URL=https://cdn.kernel.org/pub/linux/kernel | |
VERSION="${{ matrix.kernel.version }}" | |
first_char=${VERSION:0:1} | |
last_char=${VERSION: -1:1} | |
if [ $last_char == y ]; then | |
major_minor=${VERSION: 0:-1} | |
VERSION=$(curl -s $LINUX_URL/v${first_char}.x/ \ | |
| sed -e 's/<[^>]*>//g' \ | |
| grep -oP "linux-${major_minor}[0-9]+" \ | |
| sort -r -V \ | |
| head -n1 \ | |
| cut -d '-' -f2) | |
fi | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Cache kernel image | |
id: cache-kernel | |
uses: actions/cache@v3 | |
with: | |
key: ${{ matrix.os }}-${{ env.VERSION }}-${{ matrix.arch }} | |
path: | | |
${{ steps.vars.outputs.KERNEL_IMAGE }} | |
${{ steps.vars.outputs.OUT_DIR }}/vmlinux | |
- run: ls -lR | |
if: ${{ steps.cache-kernel.outputs.cache-hit == 'true' }} | |
- name: Build kernel | |
if: ${{ steps.cache-kernel.outputs.cache-hit != 'true' }} | |
uses: ./.github/actions/build-kernel | |
with: | |
os: ${{ matrix.os }} | |
arch: ${{ matrix.arch }} | |
ack: ${{ matrix.kernel.ack }} | |
kernel-version: ${{ env.VERSION }} | |
- name: Rename kernel images | |
run: | | |
SUFFIX=${{ steps.vars.outputs.KERNEL_TYPE }}-${{ env.VERSION }}-${{ matrix.arch }} | |
cp ${{ steps.vars.outputs.KERNEL_IMAGE }} ${{ steps.vars.outputs.KERNEL_IMAGE }}-$SUFFIX | |
cp ${{ steps.vars.outputs.OUT_DIR }}/vmlinux ${{ steps.vars.outputs.OUT_DIR }}/vmlinux-$SUFFIX | |
echo "SUFFIX=$SUFFIX" >> $GITHUB_ENV | |
- name: Upload kernel image artifact | |
if: ${{ matrix.os == 'ubuntu-22.04' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: kernel-image | |
path: ${{ steps.vars.outputs.KERNEL_IMAGE }}-${{ env.SUFFIX }} | |
- name: Upload vmlinux artifact | |
if: ${{ matrix.os == 'ubuntu-22.04' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: vmlinux | |
path: ${{ steps.vars.outputs.OUT_DIR }}/vmlinux-${{ env.SUFFIX }} | |
run: | |
needs: build | |
strategy: | |
fail-fast: false | |
matrix: | |
kernel: [{ack: 0, version: 5.10.y}, {ack: 0, version: 5.15.y}, {ack: 0, version: 6.1.y}, {ack: 1, version: android13-5.10-lts}] | |
arch: [arm64, x86_64] | |
timeout-minutes: 20 | |
runs-on: ubuntu-22.04 | |
env: | |
ACK: ${{ matrix.kernel.ack }} | |
ARCH: ${{ matrix.arch }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v3 | |
- name: Install common dependencies | |
shell: bash | |
run: sudo apt update && sudo apt install -y debootstrap | |
- name: Install x86_64 dependencies | |
if: ${{ matrix.arch == 'x86_64' }} | |
shell: bash | |
run: sudo apt install -y qemu-system-x86 | |
- name: Install arm64 dependencies | |
if: ${{ matrix.arch == 'arm64' }} | |
shell: bash | |
run: sudo apt install -y qemu-system-arm qemu-user-static binfmt-support | |
- name: Get real kernel version | |
run: | | |
LINUX_URL=https://cdn.kernel.org/pub/linux/kernel | |
VERSION="${{ matrix.kernel.version }}" | |
first_char=${VERSION:0:1} | |
last_char=${VERSION: -1:1} | |
if [ $last_char == y ]; then | |
major_minor=${VERSION: 0:-1} | |
VERSION=$(curl -s $LINUX_URL/v${first_char}.x/ \ | |
| sed -e 's/<[^>]*>//g' \ | |
| grep -oP "linux-${major_minor}[0-9]+" \ | |
| sort -r -V \ | |
| head -n1 \ | |
| cut -d '-' -f2) | |
fi | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Set output variables | |
id: vars | |
run: | | |
set -x | |
if [ $ACK -eq 0 ]; then | |
KERNEL_TYPE=linux | |
else | |
KERNEL_TYPE=ack | |
fi | |
SUFFIX=$KERNEL_TYPE-${{ env.VERSION }}-${{ matrix.arch }} | |
if [ $ARCH == x86_64 ]; then | |
IMAGE_NAME=bzImage-$SUFFIX | |
else | |
IMAGE_NAME=Image-$SUFFIX | |
fi | |
echo "IMAGE_NAME=$IMAGE_NAME" >> $GITHUB_ENV | |
- name: Initialize rootfs and initramfs | |
run: | | |
set -x | |
make rootfs-init | |
ROOTFS=./alpine-${{ matrix.arch }}.img make rootfs-init | |
scripts/ubuntu_debootstrap.sh jammy ${{ matrix.arch }} | |
SUDO=1 ROOTFS_DIR=./rootfs/ubuntu-jammy-${{ matrix.arch }} CPIO_FILE=ubuntu-jammy-${{ matrix.arch }}.cpio.gz make rootfs-overlay | |
- name: Setup shared/init.sh | |
run: | | |
mkdir shared | |
echo poweroff > shared/init.sh | |
chmod +x shared/init.sh | |
- name: Run kernel | |
run: | | |
QEMU_KERNEL_IMAGE=./kernel-image/$IMAGE_NAME make run | |
QEMU_KERNEL_IMAGE=./kernel-image/$IMAGE_NAME ROOTFS=./rootfs/ubuntu-jammy-${{ matrix.arch }}.img make run | |
QEMU_KERNEL_IMAGE=./kernel-image/$IMAGE_NAME INITRD=1 make run | |
QEMU_KERNEL_IMAGE=./kernel-image/$IMAGE_NAME INITRD=./ubuntu-jammy-${{ matrix.arch }}.cpio.gz make run | |
QEMU_KERNEL_IMAGE=./kernel-image/$IMAGE_NAME CPU=2 MEM=2048M QEMU_EXTRA_ARGS="" QEMU_EXTRA_KERNEL_CMDLINE="nokaslr" ROOTFS=./alpine-${{ matrix.arch }}.img make run | |
- name: Upload rootfs artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: rootfs | |
path: rootfs/alpine-${{ matrix.arch }}.img | |
release: | |
runs-on: ubuntu-22.04 | |
needs: [run, build] | |
permissions: | |
contents: write | |
steps: | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v3 | |
- name: Compute hashsums and create hashsums.txt | |
run: | | |
(cd vmlinux && sha256sum *) > hashsums.txt | |
(cd kernel-image && sha256sum *) >> hashsums.txt | |
(cd rootfs && sha256sum *) >> hashsums.txt | |
- run: ls -lR | |
- name: Set output variables | |
id: vars | |
run: | | |
set -x | |
echo "DATE=$(date +'%Y.%m.%d')" >> $GITHUB_OUTPUT | |
- name: Publish release | |
uses: softprops/action-gh-release@v1 | |
with: | |
prerelease: true | |
tag_name: ${{ steps.vars.outputs.DATE }}-${{ needs.build.outputs.SHORT_HASH }} | |
files: | | |
vmlinux/* | |
kernel-image/* | |
rootfs/* | |
hashsums.txt |