-
Notifications
You must be signed in to change notification settings - Fork 26
81 lines (75 loc) · 2.75 KB
/
build-linux.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: Build Linux
on:
workflow_call:
inputs:
kernel-repo:
description: 'The Linux kernel repository to use.'
default: 'torvalds/linux'
required: false
type: string
rev:
description: 'The revision to build at.'
# By default just use the default branch HEAD.
default: ''
required: false
type: string
config:
description: 'Path to the kernel configuration to use.'
required: true
type: string
outputs:
kernel-artifact-url:
description: "URL of the built (and uploaded) Linux kernel"
value: ${{ github.api_url }}/repos/${{ github.repository }}/actions/artifacts/${{ jobs.build.outputs.kernel-artifact-id }}/zip
jobs:
build:
name: Build Linux
runs-on: ubuntu-latest
outputs:
kernel-artifact-id: ${{ steps.upload-linux-kernel.outputs.artifact-id }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
id: restore-cached-kernel
with:
path: build/arch/x86/boot/bzImage
key: linux-kernel-${{ inputs.rev }}-${{ hashFiles(inputs.config) }}
- if: steps.restore-cached-kernel.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: ${{ inputs.kernel-repo }}
ref: ${{ inputs.rev }}
fetch-depth: 1
path: linux/
- if: steps.restore-cached-kernel.outputs.cache-hit != 'true'
name: Install required tools
run: sudo apt-get install -y libelf-dev
- if: steps.restore-cached-kernel.outputs.cache-hit != 'true'
name: Build kernel
run: |
config=$(readlink --canonicalize-existing ${{ inputs.config }})
build=$(pwd)/build/
cd linux/
export KBUILD_OUTPUT="${build}"
mkdir "${KBUILD_OUTPUT}"
KCONFIG_ALLCONFIG="${config}" make O="${KBUILD_OUTPUT}" allnoconfig
echo "::group::config"
cat "${KBUILD_OUTPUT}/.config"
echo "::endgroup::"
make O="${KBUILD_OUTPUT}" --jobs $(($(nproc) * 2))
- if: steps.restore-cached-kernel.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: build/arch/x86/boot/bzImage
key: linux-kernel-${{ inputs.rev }}-${{ hashFiles(inputs.config) }}
- uses: actions/upload-artifact@v4
id: upload-linux-kernel
# TODO: Having a single path/name may be problematic should we
# ever opt to reusing this workflow multiple times with
# different inputs.
with:
name: linux-kernel
if-no-files-found: error
# The kernel image is already compressed.
compression-level: 0
path: build/arch/x86/boot/bzImage