@@ -3,12 +3,6 @@ name: Hyperion Kernel Build CI
33on :
44 workflow_dispatch :
55
6- env :
7- KERNEL_VERSION : " 6.19.6"
8- HYPERION_VERSION : " 0.1.0"
9- KBUILD_BUILD_USER : " Soumalya Das"
10- KBUILD_BUILD_HOST : " hyperion-ci"
11-
126permissions :
137 contents : write
148 actions : write
@@ -17,32 +11,80 @@ jobs:
1711 validate-config :
1812 name : Validate Hyperion Config
1913 runs-on : ubuntu-latest
14+ outputs :
15+ VERSION : ${{ steps.parse-config.outputs.VERSION }}
16+ PATCH : ${{ steps.parse-config.outputs.PATCH }}
17+ SUB : ${{ steps.parse-config.outputs.SUB }}
18+ EXTRA : ${{ steps.parse-config.outputs.EXTRA }}
19+ LOCAL : ${{ steps.parse-config.outputs.LOCAL }}
20+ TAG : ${{ steps.parse-config.outputs.TAG }}
2021 steps :
2122 - uses : actions/checkout@v4
2223
23- - name : Validate hyperion.config
24+ - name : Validate and parse hyperion.config
25+ id : parse-config
2426 run : |
2527 python3 - << 'EOF'
26- with open('hyperion.config') as f: lines = f.readlines()
27- errs=[]
28- for i,l in enumerate(lines,1):
29- l=l.strip()
30- if not l or l.startswith('#'): continue
31- if '=' not in l: errs.append(f"Line {i}: No '=': {l}")
32- elif not l.startswith("CONFIG_"): errs.append(f"Line {i}: needs CONFIG_: {l}")
33- if errs:
34- print("\n".join(errs))
35- exit(1)
36- print("Config OK")
28+ import re
29+ import sys
30+
31+ config = {}
32+ with open('hyperion.config') as f:
33+ for line in f:
34+ line=line.strip()
35+ if not line or line.startswith('#'):
36+ continue
37+ if '=' not in line:
38+ print(f"Invalid line: {line}")
39+ sys.exit(1)
40+ key, val = line.split('=', 1)
41+ config[key.strip()] = val.strip().strip('"')
42+
43+ if 'CONFIG_VERSION' not in config or config['CONFIG_VERSION']=='':
44+ print("Missing mandatory CONFIG_VERSION")
45+ sys.exit(1)
46+
47+ def parse_int(key, default=0):
48+ val = config.get(key, '')
49+ if val=='':
50+ return default
51+ try:
52+ iv = int(val)
53+ if iv < 0:
54+ raise ValueError
55+ return iv
56+ except ValueError:
57+ print(f"Invalid {key} value: {val} (must be non-negative integer)")
58+ sys.exit(1)
59+
60+ VERSION = parse_int('CONFIG_VERSION')
61+ PATCH = parse_int('CONFIG_PATCHLEVEL')
62+ SUB = parse_int('CONFIG_SUBLEVEL')
63+ EXTRA = config.get('CONFIG_EXTRAVERSION','') or ''
64+ LOCAL = config.get('CONFIG_LOCALVERSION','') or ''
65+
66+ tag_suffix = LOCAL.split('-Hyperion-')[-1] if '-Hyperion-' in LOCAL else LOCAL
67+ TAG = f"v{VERSION}.{PATCH}.{SUB}{tag_suffix}"
68+
69+ print(f"::set-output name=VERSION::{VERSION}")
70+ print(f"::set-output name=PATCH::{PATCH}")
71+ print(f"::set-output name=SUB::{SUB}")
72+ print(f"::set-output name=EXTRA::{EXTRA}")
73+ print(f"::set-output name=LOCAL::{LOCAL}")
74+ print(f"::set-output name=TAG::{TAG}")
3775 EOF
3876
3977 build-kernel :
4078 name : Build Linux Hyperion Kernel
4179 runs-on : ubuntu-latest
4280 needs : validate-config
4381 env :
44- KERNEL_VERSION : 6.19.6
45- HYPERION_VERSION : 0.1.0
82+ KERNEL_VERSION : ${{ needs.validate-config.outputs.VERSION }}
83+ PATCHLEVEL : ${{ needs.validate-config.outputs.PATCH }}
84+ SUBLEVEL : ${{ needs.validate-config.outputs.SUB }}
85+ EXTRAVERSION : ${{ needs.validate-config.outputs.EXTRA }}
86+ LOCALVERSION : ${{ needs.validate-config.outputs.LOCAL }}
87+ TAG_NAME : ${{ needs.validate-config.outputs.TAG }}
4688 KBUILD_BUILD_USER : Soumalya Das
4789 KBUILD_BUILD_HOST : hyperion-ci
4890
@@ -69,27 +111,32 @@ jobs:
69111 if : steps.cache-tar.outputs.cache-hit != 'true'
70112 run : wget -q https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-${{ env.KERNEL_VERSION }}.tar.xz
71113
72- - name : Prepare build tree
114+ - name : Prepare build tree safely
73115 run : |
74116 mkdir -p .cache-build
75- if [ ! -d ".cache-build/linux-${KERNEL_VERSION}" ]; then
76- tar -xf linux-${KERNEL_VERSION}.tar.xz -C .cache-build
77- mv .cache-build/linux-${KERNEL_VERSION}* .cache-build/linux-${KERNEL_VERSION}
117+ cd .cache-build
118+ if [ ! -d "linux-${KERNEL_VERSION}" ]; then
119+ tar -xf ../linux-${KERNEL_VERSION}.tar.xz
120+ EXTRACTED_DIR=$(tar -tf ../linux-${KERNEL_VERSION}.tar.xz | head -1 | cut -f1 -d"/")
121+ if [ "$EXTRACTED_DIR" != "linux-${KERNEL_VERSION}" ]; then
122+ mv "$EXTRACTED_DIR" "linux-${KERNEL_VERSION}"
123+ fi
78124 fi
125+ cd ..
79126
80127 - name : Install build dependencies
81128 run : |
82129 sudo apt-get update -qq
83130 sudo apt-get install -y --no-install-recommends \
84131 build-essential libncurses-dev bison flex libssl-dev libelf-dev \
85- dwarves bc pahole git make gcc xz-utils zstd cpio perl tar rsync
132+ dwarves bc pahole git make gcc zstd cpio perl tar rsync
86133
87134 - name : Configure kernel
88135 run : |
89136 cd .cache-build/linux-${KERNEL_VERSION}
90137 cp ../../hyperion.config .config
91138 make olddefconfig \
92- LOCALVERSION="-Hyperion-${HYPERION_VERSION }" \
139+ LOCALVERSION="${LOCALVERSION }" \
93140 KBUILD_BUILD_USER="${KBUILD_BUILD_USER}" \
94141 KBUILD_BUILD_HOST="${KBUILD_BUILD_HOST}"
95142
@@ -100,42 +147,46 @@ jobs:
100147 git apply "$p" || patch -p1 < "$p"
101148 done || true
102149
103- - name : Build kernel (incremental)
150+ - name : Build kernel
104151 run : |
105152 cd .cache-build/linux-${KERNEL_VERSION}
106153 make -j$(nproc) \
107- LOCALVERSION="-Hyperion-${HYPERION_VERSION }" \
154+ LOCALVERSION="${LOCALVERSION }" \
108155 KBUILD_BUILD_USER="${KBUILD_BUILD_USER}" \
109156 KBUILD_BUILD_HOST="${KBUILD_BUILD_HOST}" \
110157 KBUILD_BUILD_TIMESTAMP="$(date -u '+%Y-%m-%d %H:%M:%S')" \
111158 2>&1 | tee build.log
112159
113- - name : Verify build
114- run : |
115- ls -lh .cache-build/linux-${KERNEL_VERSION}/arch/x86/boot/bzImage
116- strings .cache-build/linux-${KERNEL_VERSION}/arch/x86/boot/bzImage | grep "Hyperion"
117-
118- - name : Package artifacts into .tar.xz
160+ - name : Package artifacts into .tar.zst
119161 run : |
120162 cd .cache-build/linux-${KERNEL_VERSION}
121- tar -cJf ../../Hyperion-Kernel-${KERNEL_VERSION}.tar.xz \
163+ tar --zstd -cf ../../Hyperion-Kernel-${KERNEL_VERSION}.tar.zst \
122164 arch/x86/boot/bzImage \
123165 Module.symvers \
124166 build.log \
125167 ../../hyperion.config
126168
127- - name : Create GitHub Release
169+ - name : Generate SHA256 checksum
170+ run : |
171+ sha256sum Hyperion-Kernel-${KERNEL_VERSION}.tar.zst > Hyperion-Kernel-${KERNEL_VERSION}.sha256
172+
173+ - name : Clean temporary build dirs
174+ run : rm -rf .cache-build/linux-${KERNEL_VERSION}
175+
176+ - name : Create GitHub Release with dynamic tag
128177 uses : softprops/action-gh-release@v2
129178 with :
130- tag_name : v ${{ env.KERNEL_VERSION }}-Hyperion-${{ env.HYPERION_VERSION }}
131- name : Linux ${{ env.KERNEL_VERSION }}-Hyperion-${{ env.HYPERION_VERSION }}
179+ tag_name : ${{ env.TAG_NAME }}
180+ name : Linux ${{ env.TAG_NAME }}
132181 env :
133182 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
134183
135- - name : Upload compressed kernel archive
184+ - name : Upload compressed kernel archive and checksum
136185 uses : softprops/action-gh-release@v2
137186 with :
138- files : Hyperion-Kernel-${{ env.KERNEL_VERSION }}.tar.xz
187+ files : |
188+ Hyperion-Kernel-${KERNEL_VERSION}.tar.zst
189+ Hyperion-Kernel-${KERNEL_VERSION}.sha256
139190 env :
140191 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
141192
0 commit comments